You are on page 1of 3

MSKÜ - CENG 2034 - Operating Systems - Spring 2022-2023

Assignment III (40 pts)

Burak Ekici

Assigned : May the 12th , 23h55


Due : May the 21st , 23h55

1 Objective

The main purpose of the assignment is to write a C program that simulates non-preemptive First-Comes-First-
Served (FCFS) schedulers such that
• processes and the dispatcher are individually represented by pthreads;
• processes do not execute specific tasks, instead they just sleep in the amount of their burst times.
Therefore, “execution” means “sleeping” in this context.
The scheduler is supposed to function with a single core CPU, namely only one process, including the dis-
patcher, could take the CPU control at a time. Others have to wait for the currently running process to ter-
minate the task. Please arrange the synchronization and signalization among processes (and the dispatcher)
accordingly.

2 Tasks

Note that the details of below employed structures such as PROCESS, NODE, QUEUE and BOARD alongside a few
useful functions could be found in the attached file FCFS.c.
The scheduler is supposed to govern five processes with the following burst times and the listed arrival order
(p1 comes first):
process id burst time
p1 5
p2 4
p3 3
p5 1
p4 2
In these lines, implement in FCFS.c below detailed functions, leaving the signatures unchanged:
a) (5 pts) void enQueue(QUEUE ∗q, NODE ∗n) ;
takes an “ordinary queue” q and a node n, and joins n at back of the line of q.
b) (5 pts) NODE ∗ deQueue(QUEUE ∗q) ;
takes an “ordinary queue” q, fetches, and returns the node in the front line.
c) (10 pts) void dispatcher (BOARD ∗b) ;
takes a board b, fetches the front line process and submits it to the CPU for execution (sleeping for
burstTime seconds) purposes.
Note that the dispatcher repeats the above task until the queue becomes empty.

page 1 of 3
d) (15 pts) void process1 (BOARD ∗b) ;
void process2 (BOARD ∗b) ;
void process3 (BOARD ∗b) ;
void process4 (BOARD ∗b) ;
void process5 (BOARD ∗b) ;
takes the board and allows for each process to sleep in accordance with their burst times.
e) (5 pts) int main (void) ;
• arranges process, node, queue initializations;
• matches every single process (and the dispatcher) with a pthread;
• ensures that the threads are not canceled but are joint with the main thread at the end of the
program execution.

page 2 of 3
Nota Bene (in general).
1. receive support from helper functions if needed;
2. the attached file (FCFS.c) must be the starting point;
3. do not remove or modify the types or functions contained in the file FCFS.c, and implement your functions
obeying the signatures stated above.

Important Notice:
• Collaboration is strictly and positively prohibited; lowers your score to 0 if detected.
• Any submission after 23h55 on May the 21th will NOT be accepted. Please beware and respect the
deadline!
• Implement your code within a file named yourname_surname.c, and submit it either in the raw form as it is
or in the ZIP compressed form. Do not RAR files.

page 3 of 3

You might also like