No holidays for real geeks ^^

Hi everyone !

I have no pretty screenshot for you today, because I don’t have internet access on my own computer here. But there’s sure a lot of big news.

  • I think that I’ve reached the end of a big and fruitful code cleanup in the bootstrap code. Unless I find some new horror lurking in the dark, of course… It does the same thing as before (preparing kernel startup), but in a much cleaner and smarter way.
  • This means that I’ve begun serious work on the kernel, starting with debugging code as usual. Thanks to some nice features of C++ and the large amount of spare time I’ve got, I’ve completed fairly quickly something that took me weeks to do in C, and in a much cleaner way.
  • Then I continued to follow my roadmap, only to realize that some things were horribly wrong with it (blame my inexperience with OS development).  Among other things, I needed dynamic memory allocation much earlier than I thought in order to write code of the finest quality. I’ve hence made a list of changes to be made, and started work on dynamic memory allocation.

Apart from that, well… I try not to spend all of my spare time writing OS code, working on a poster related to my internship, and reading books about classical fields theory. It’s probably bad for my mental health, and certainly bad for my physical weight. So I benefit from the nice weather, cyclist-friendly roads, and cold sea that we have here too, plus role-play a little bit and play “poker menteur” (literally “lying poker”, an interesting game based on the rules of poker with a much stronger focus on the ability to bluff).

But as I grow older, it’s frightening how much I start to love stubbornly working on something more and more, whether it’s for professional reasons or as a hobby…

3 thoughts on “No holidays for real geeks ^^

  1. Amenel July 25, 2010 / 12:40 am

    Stubbornly working on something more and more… isn’t that “dedication”? Unless it’s extreme, it won’t deserve the “obsession” qualification. Hope you haven’t reached that point…

    Have you ever read the story from one of the developers of the Atari ST’s OS? It’s in two installments: and
    Worth the read regardless of whether you’re writing an OS or not :-)

    Could you give an idea of how you manage dynamic memory allocation? I’ve always wondered how it’s handled at the low levels. Are there specific instructions at the hardware level that you (plan to) use? Is it that the memory is seen as a whole and given out chunk by chunk while keeping a list of who has been given what?

  2. Hadrien July 26, 2010 / 3:47 pm

    About dedication : Well, it could be. I didn’t even know about that use of “dedication” in English ! ^^’ In French, “obsession” and its lexical field are commonly used as an exageration, but it could well be specific to French…

    About the story : this is one of the reasons why I prefer computer science as a hobby rather than as a job ;)

    Dynamic memory allocation : Well, as far as I know, there are not standard instructions for doing memory allocation on my current development platform (x86_64). Even if there are some, they are probably extremely limited and only available in real mode (16-bit compatibility mode from the stone age that helps DOS to still boot on modern PC computers without a single glitch). And they’re probably not that standard when you think of it, like most things provided by the BIOS or its EFI cousin in the PC world.

    What the hardware does provide is a virtual memory mechanism, paging. Virtual memory allows one to control, to some extent, how programs access memory. It introduces protection mechanisms (you can forbid programs to access a region of RAM, or to read/write/execute data from there), and it introduces a translation layer between the memory addresses manipulated by software and the memory addresses that they actually manipulate in RAM. As an example, you can have any access to memory address 0x1000 target in fact memory address 0x2000 without software even knowing about that. You can also have different virtual addresses target the same physical addresses (ie accesses to address 0x1000, 0x2000, and 0x3000 are all redirected to address 0x4000).

    Paging has countless applications. A simple one is to prevent a process from accessing and modifying data which belongs to other processes and to introduce stack overflow protection. Another one is to have programs believe that they access a large continuous chunk of memory while they are in fact accessing multiple fragments spread across physical memory where space is available. A third application is swapping, that is have programs believe that they access RAM while the operating system silently redirects their memory accesses to HDD.

  3. Hadrien July 26, 2010 / 4:02 pm

    Now, how does it work in practice :

    1/Like operating systems from the dark ages of DOS, you have a mechanism which directly manages physical memory, storing in a map which process “owns” what and which memory remains free.

    2/You then create a mechanism which manages virtual memory, based on the previous one. It offers ability to handle memory protection and address translation.

    3/On top of those mechanisms, you put your allocation algorithms. A simple example could be : find the requested amount of space in the form of non-contiguous free chunks of physical memory, mark them busy, then create a contiguous block of virtual memory which points to those chunks of physical memory and set up its protection bits so that the process may access it in a controlled way. Finally, return the address of the block of virtual memory to the process.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s