Subject:
|
Re: My problems with adding a Best Fit algorithm for memory management to kernel/mm.c
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Thu, 11 Dec 2003 02:34:34 GMT
|
Viewed:
|
4191 times
|
| |
| |
In lugnet.robotics.rcx.legos, Michael Martelli wrote:
> When I did not shut off the RCX between program executions
> here is the allocation of memory
>
> Addr PID Size
> --------------------
<snip>
> AFD6 AD50 000A
<snip>
> B648 AFDA 006B
<snip>
I didn't have time to mention this in my earlier post, but this memory dump
points out a potential problem with the way BrickOS allocates memory for
programs. In the above memory dump, the 0x6B words at 0xB648 represent a
downloaded BrickOS program. The memory block is owned by PID 0xAFDA which is
the program manager task (that's the block with 0xA words at 0xAFD6). However,
when you turn the RCX off, BrickOS shuts down the program manager and releases
the memory for its task but not any memory owned by the program manager (since
it is a kernel task). So, the downloaded program lives on in memory with a
non-existent task as owner.
Now, when you turn the RCX back on, it starts up and allocates memory for the
various kernel tasks. With a first fit malloc() algorithm, it just so happens
that the tasks get allocated the same memory that was released on power off. So
everything is peachy. But, with the worst fit algorithm in place, the program
manager task gets moved to another address and so the downloaded program PID
points to a non-existent task.
In the (extremely) unlikely event a user program starts up a task and it gets
allocated to 0xAFDA, then when this task exits it will also unwittingly free up
the memory used by the downloaded program (unbeknownst to the program manager)
and a crashed OS will no doubt quickly be the result.
Simply changing the PID for downloaded programs to an impossible value (like 1)
would solve the problem.
Mark
|
|
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
|
|
|
|