COSC 3360/6310 — FUNDAMENTALS OF OPERATING SYSTEMS
ASSIGNMENT #1: PROCESS SCHEDULING
                               Due Wednesday 15, February, 2023 at 11:59:59 PM
OBJECTIVE                                                       When a process requests a lock and finds it in the
This assignment will introduce you to process scheduling        UNLOCKED state, it moves the lock to the LOCKED state and
and process synchronization.                                    proceeds.
                                                                When the same process finds the lock in the LOCKED state,
SPECIFICATIONS
You are to simulate the execution of a stream of interactive    it waits until the lock returns to the UNLOCKED state before
processes by a time-shared system with NCORES processing        moving it back to the LOCKED state and proceeding.
cores, a solid-state drive and 64 locks, all initially in       Processes releasing a lock never wait and always leave the
UNLOCKED state.                                                 lock in the UNLOCKED state.
We will assume that we can describe each process by its start   I/O requests: We will assume that each process will run in
time and a sequence of resource requests whose durations are    its own window so there will never be any queueing delay.
known a priori.
Input Format: Your program should read its input from           Output specifications: Each time a process starts or
stdin (C++ cin) and use input redirection as in:                terminates your program should output a summary report
                                                                containing:
     $ assignment1 < input1.txt
                                                                   1. The current simulated time
This input will look like:
                                                                   2. The sequence number of the process that either started
NCORES 2        // system has two cores                                or terminated
START       10 // new process starts at t= 10ms
CPU 200 // request 200ms of core time                              3. The current number of busy cores
LOCK 1 // request lock on lock #1                                  4. The contents of the ready queue
CPU 10 // request 10ms of core time                                5. For each process in main memory and the process
SSD 300 // request 300ms SSD access                                     that has just terminated, one line with: the process
CPU 100 // request 100ms of core time                                   sequence and whether it is in the READY, RUNNING,
SSD 300 // request 300ms SSD access                                     BLOCKED or TERMINATED state.
CPU 10 // request 10ms of core time
UNLOCK 1 // release lock on lock #1                             Error recovery: Your program can assume that its input will
CPU      200 // request 200ms of core time                      always be correct.
OUTPUT 10 // write to display for 10ms                          PROGRAMMING NOTES
CPU       10 // request 10ms of core time                       Your program should start with a block of comments
END      // terminate process                                   containing your name, the course number, and so on. It
START 90 // new process starts at t = 90ms                      should contain functions and these functions should have
CPU 30 // request 30ms of core time                             arguments.
...
END // (last) process terminates                                Before starting your program, you might want to look at the
                                                                section of process states in the second chapter of the notes.
Each process will execute each of its computing steps one by    Since you are to focus on the scheduling actions taken by the
one and in the specified order. Process start times will        system, you are simulating, your program will only have to
always be monotonically increasing.                             act whenever
Memory allocation: We assume that memory is large                 1. A process starts.
enough to contain all user processes.
                                                                  2. A process releases a core or a lock.
Core scheduling: Your program should schedule core usage
according to a First-Come First-Served policy. Therefore,         3. A process releases the SSD.
processes waiting for a core can be stored in a FIFO queue        4. A process completes an I/O operation.
(ready queue).                                                  You should simulate the flow of time by having a global
SSD scheduling: SSD accesses should be performed in             variable keeping the current time and incrementing it every
mutual exclusion according to the same First Come-First         time you move from one scheduling action to the next.
Served policy as the system cores.                              These specifications were updated last on Sunday, January
The system locks: The system has 64 locks numbered from         15, 2023. Check the course respective Teams and Prulu
0 to 63 that processes can use to access critical shared        pages for corrections and updates.
resources in mutual exclusion. Each lock can be either in the
LOCKED or in the UNLOCKED state.