OS Micro kernel Design & Simulation
Class project
for ECS 289D - Advanced Operating Systems
Description:
1: Design of the Scheduler and Data Structures (Code)
Objective: To design the scheduler, the process control block (pcb),
pcb-table, queue structures of the sample OS using threads.
Each
of the processes are implemented using POSIX threads. The scheduler is
also another thread (in the DETACHED) state.
What does the thread do?
As this is a scheduler simulation, the threads implement
dummy/artificial procedures, which just print the Process Id in a loop.
On termination of the loop, the process exits.
What does the scheduler do?
The scheduler algorithm is as follows:
|
Data
structures:
A. Process Control Block
A PCB is represented by a structure with the following fields:
* Process ID (represented by the index of the PCB in the PCB-TABLE)
* Priority (lower numbers have higher priority; all queues in FCFS
queue have highest priority of 0)
* State (can be RUNNING or READY)
All the PCBs are accessed via a PCB-TABLE, where each entry is a
pointer to the corresponding PCB.
B. Queue
We implement this as a linked list, where each node contains a pointer
to the PCB structure. Normal queue operations are supported.
When the processes need to block, they use the technique of waiting on
a semaphore (unique to the process). The scheduler signals the same
semaphore when it has to acitvate the process. Similar use of a
semaphore is made when the scheduler has to woken up.
2: Process Management (Code)
Objective: To provide the process management module
Here, we build upon the services of the scheduler that we constructed and provide 4 process management funtions, viz.
3: Process Management (Code)
Objective: To provide the inter-process synchronization and
communication module
A. Synchronization via Semaphores
We define a structure 'sema' which encapsulates all the attributes of a
semaphore. The following operations are supported:
B.
Communication via Mailboxes
We define a structure 'mailbox' which encapsulates all the attributes
of a mailbox. The following operations are supported:
These
make use of 'sema' objects to control the sending and receiving of data.
C. Message queues
These are similar to the process queues implemented earlier and support
the same operations. However each node of the queue is a message, not a
PCB.