I always wanted to make an OS, ever since i first read a mini article on the topic back at HTS 3 years ago.
I finally started 3 days ago. Its remarkably easy once you get started, you just gotta be extremely patient, play around with ALOT of very low level c, and read alot of documentation for VGA drivers and other such boring things.
I was thinking of posting bits of the source, or the iso's or whatever once theres something worth showing, but for now i'd just like to ask a fairly quick question (and i felt like showing off slightly, cos im fucking proud of myself lol).
Does anybody have any clue how i could implement my own version of malloc() without using any system calls except:
These are the ones i've got to work so far. Aswell as the worlds crappiest print function, and a pimped, colour, ascii art logo. Theres also CPU and floppy detection cos i worked out how to do that using the importb() asm ported function.
RE: My OS
Posts: Location: Joined: 01.01.70 Rank: Guest
Posted on 10-07-07 03:10
You're going to have to manage start managing your own heap for allocation calls :)
// Check to see if there's anything left
if( (nextBlock + size) > (myHeap + (100 * 1024)) )
ptr = (void *)nextBlock;
nextBlock += size;
Going further than that you can use a linked list to keep track of how much memory is being used and the blocks next to it (but as the first, say, 64 bytes of each allocation) and work your own algorithm up to handle freeing & re-allocating memory etc.
I think the Thinking in C++ 2nd edition book covers mini object allocators which was an interesting read :)