![]() |
|
#1
|
||||
|
||||
Memory allocation issueHey, guys.
How about this idea for memory handling by an OS : I wish that my OS will have a memory allocation table for some tasks. What I did this far is create an envelope function called smalloc that adds any allocation to the memory allocation table. Next step is to add process ID into account (I will probably use a chained hash table), but I still didn't implement that part so I'm leaving the process ID out for now. Here is what I did this far as a skeleton. Any suggestions ? CPP / C++ / C Code:
Thanks in advance for any critique or insight, Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#2
|
||||
|
||||
Re: Memory allocation issueHi Kobi,
Just my thought: We can use typedef to avoid writing struct anode ... I think there is no // comment in C language. We should use /*comment*/ instead. Cheers, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#3
|
||||
|
||||
Re: Memory allocation issueQuote:
I think you are right. The reason I didn't write it down as [b]typedef[b] is that I plan on having all the types that my OS uses in header files. But you are correct, I probably should have mentioned it, or post the specific typedef's. Soon I will post it, after I decide exactly how things should happen (some types will be builded upon other types). Quote:
You are correct Thanks ,Paramesh. Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#4
|
|||
|
|||
Re: Memory allocation issueQuote:
I'm not sure how you are going to use this. Garbage collection or what? My observation is that if you are going to allocate blocks of memory with the idea of freeing them up at some time in the future, then I think that the anode struct should have a size member in addition to the memory address pointer. Regards, Dave |
|
#5
|
||||
|
||||
Re: Memory allocation issueQuote:
True. I added a memory_blocks counter and the intention was to have knowledge of memory blocks allocated. Of course you are correct, and this information will be stored for each allocation (as well as process ID I'll add). The main idea is to "control and monitor" memory allocation. A garbage collection is one usage I had in mind (When a process is terminated, I scan the hash table and free any unfreed memory allocated by this process). Here it is, till now (Paramesh, I still didn't insert the typedef part - But I will soon). CPP / C++ / C Code:
Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#6
|
||||
|
||||
Re: Memory allocation issueHere is the code untill now, still without the hash table (the memory allocation table is a "plain" linked list).
CPP / C++ / C Code:
As always, critique and suggestions are welcome. Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#7
|
||||
|
||||
Re: Memory allocation issueThis is what I've done this last hour :
mem.h CPP / C++ / C Code:
smalloc.c CPP / C++ / C Code:
Soon to come : remove_allocation, sum_allocations (by given pid). Kobi. __________________
It's actually a one time thing (it just happens alot). |
Recent GIDBlog
Halfway done! by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pointer Usage in C++: Beginner to Advanced | varunhome | C++ Forum | 0 | 19-Aug-2005 09:25 |
| Computer resets - weird memory slot issue | SpikeyUK | Computer Hardware Forum | 7 | 22-Jul-2005 18:15 |
| [Tutorial] Pointers in C (Part I) | Stack Overflow | C Programming Language | 1 | 08-Apr-2005 18:35 |
| 3D array dynamic memory allocation | cjwatchdog | C Programming Language | 3 | 20-Feb-2004 15:27 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The