For better understanding the underlying principle of Operating System, I reimplement some of important module of Xinu OS, which is described from the book 《Operating System Design: The Xinu Approach, Second Edition》, written by Douglas Comer.
NOTE: this project is NOT a working OS but some reimplemented essential module from the original X86 version Xinu. The basic structure is depicted in this image.
The reimplemented modules include:
- process queue. Gather multiple queues inside a statically allocated array in queue.go file;
- process management, including process rescheduling, rescheduling defer, process suspend, resume, create function in resched.go and process.go files;
- semaphore management, including create, delete and reset semaphore. Waiting on a semaphore and signal the arrival of release of semaphore. All in semaphore.go file;
- Lower-level IPC of message. Including the message send and receive, in file message.go;
- process preemption and time-delay function, implemented in separate clock.go file;
- High-level message passing with ports. It supports message queuing, synchronously sending messages to a port, synchronously receiving messages from a port. It very much like the golang's channel. ^_^;
- Basic memory management, including allocation and free of heap and stack memory at oppositon direction, all in memory.go file;
- Buffer pool management, including allocating and freeing of buffer from pool, which has limited memory. Buffer pool is one of the memory partition mechanism that split free memory into independent subsets. Thus, the system can guarantee that excessive requests will not lead to global deprivation.
Some modifications compared with the original X86 version Xinu :
- Header files and C source code files, which share some similarity in functionality, have been combined into a single .go file. So most .c files under the 'system' directory have combined into .go files under the 'include' directory ;
eg: The functions and struct defination from queue.h, queue.c and getitem.c have been reimplement in queue.go out of simplicity. - All the uniersal return constants have been redefined by error type out of consideration for the (return values, error indication) pattern in golang ;
- The first letter of most of names, including function name, constant, global variables, customed type, struct field etc, have been capitalized according to the naming convention of golang;
eg: enqueue -> Enqueue; isbadqid -> IsBadQid.