Subject:
|
Re: My problems with adding a Best Fit algorithm for memory management to kernel/mm.c
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Sun, 7 Dec 2003 18:46:15 GMT
|
Viewed:
|
4189 times
|
| |
| |
In lugnet.robotics.rcx.legos, Mark Riley wrote:
> So, if I understand you correctly, your concern is that the OS tasks move around
> the first time you power off & on, but not anytime thereafter? Assuming this to
> be the case, then:
>
> 1) When you first download BrickOS, there is a large chunk of memory at
> [ADEA-EF2C). There are also a few smaller chunks in high memory, but for the
> most part your worst fit algorithm will ignore these. From this large chunk
> gets allocated the various OS tasks (and stacks, etc...) since the worst fit
> algorithm picks the largest free chunk from which to allocate.
>
> 2) You download your test program and it gets allocated 6B words at B648.
>
> 3) You turn off the RCX and all the tasks are terminated and their memory freed
> up. Every time you turn off the RCX, this memory will be freed. However, your
> program will stay in memory. Since this is the case, it has fragmented the
> initial large chunk of memory into two chunks: [ADEA,B648) and [B722,EF2C).
>
> 4) You turn on the RCX and BrickOS starts up the various OS tasks and these
> allocate memory from the largest available memory chunk which is now at
> [B722,EF2C).
>
> 5) Go to step 3.
>
> So, downloading your test program has fragmented memory and causes any
> subsequent allocations (using the worst fit algorithm) to use the largest free
> memory block (which happens to be located after your program in memory).
>
> There is one thing that bothers me which you did not mention. Here is the first
> five lines of your second memory dump:
>
> Addr PID Size
> --------------------
> ADCA 0000 042D
> B648 AFDA 006B
> B072 AD50 000A
> B71A AD50 0040
> B79E AD50 0004
>
> See the address B072? It's not in sequential order. There are also two other
> blocks at B74E and B766 in the same dump which are out of order. Are these
> typos or perhaps transmission/reception errors from your test program?
>
> Mark
Mark,
Thanks again thanks for the reply.
Yes, my main comcern is that the OS tasks move around only after the first power
off & on, no time else.
And also it was just a typo, the blocks are in order I was looking at the wrong
copy of my layout when I was writting that up (but the idea of the layout was
correct, the Addr, though were not).
What you wrote down as the steps that are occuring, seem correct and I do
understand what is happening. I guess the only thing I was unsure about is that
when I turn the RCX off the current OS task that were allocated get freed, that
is correct? If that is correct, then my algorithm does work becuase, as you
said, the biggest block - following Worst Fit, is the block after my User
Program.
That makes perfect sense. So to sum up, the only thing that stays in memory
after I turn the RCX off is that user program and those 3 resereved blocks (PID
= FFFF). The OS tasks get freed (all 15 with PID=AD50 and the 3 with PID=B202).
Even the blocks that I allocated get deleted because their parent task (my user
program) gets killed by the OS. So the only thing left is my program itself.
I think I understand it now (provided my above paragraph is correct), for some
reason I was not thinking like an operating system. Thanks for clearing this up
for me.
|
|
Message has 1 Reply:
Message is in Reply To:
14 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|