Skip to content

Resource Allocation/Deallocation

May 28, 2009

The more I work on the system the more obvious it is that I’m going to have to be a little more clever when allocating and, particularly, deallocating memory. I’m most concerned with deallocating memory when a task ends. User heap memory is no problem, as it is part of a memory map that gets discarded and (I think) kernel heap allocation doesn’t occur in user tasks. However there is still shared memory to worry about. Currently it’s up to the task to make sure that it deallocates everything – but that’s really not good enough; it should happen automatically.

I’m thinking at the moment of adding an additional field to each allocated block of memory to record the task of the PID that it belongs to. A separate task could then clean up resources once a task ends (and perhaps periodically sweep the system looking for zombie resources). It doesn’t sound too difficut to implement.

Actually, I’m not totally convinced that the use of shared memory is a good thing (except where absolutely necessary) – there are obvious security implications. It’s needed to pass information between tasks (other than the limited amount of data that can be passed directly in a message), but there must be an alternative way of doing this. I must look carefully at where shared memory is used and whether it is necessary.

There’s also the separate problem of keeping track of which task an FCB belongs to so that the filesystem can deallocate it when it is no longer needed.

From → IanOS

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: