0% found this document useful (0 votes)
4 views

Midterm_solution

Uploaded by

salihsafaakgul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Midterm_solution

Uploaded by

salihsafaakgul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

İÜC, Computer Eng, Operating Systems, A.

KURT, Fall 2024


Midterm, 70 min. 15.11.2024
No_________________Name:_______________________________
Write your answers on this paper
1) (10 points) List the components (parts) of a process in memory:
a) Code (text)
b) Data (variables)
c) Heap
d) Stack
2) (10 points) Draw the diagram of process states ()
3) (30 points) Consider the following processes in the ready queue. Assume time quantum is 5
Process Burst time
P1 12
P2 5
P3 9
a) Give the Gannt chart for the schedule using Round Robin scheduling.
P1(5sn) P2(5sn) P3(5sn) P1(5sn) P3(4sn) P1(2sn)
b) Give the completion times, turnaround times, wait times, response times for all processes.
Turnaround Time = Completion Time – Arrival Time
Waiting Time = Turnaround Time – Burst Time
Response Time = Start time (start of first execution) – Arrival Time
Process Burst Arrival Waiting Start Completion Turnaround Response
P1 12 0 14 0 26 26 14
P2 5 0 5 5 10 10 5
P3 9 0 15 10 24 24 15
c) Give the average waiting time: (14 + 5 + 15) / 3 = 11.33

4) (20 points) Write a C program using fork(),wait(), etc. functions which outputs “Hello world”; where “Hello” is printed in the child
process and “ world” is printed in the parent process. Note that the output should not be “ worldHello”.

int main() {
pid_t pid = fork();
if (pid < 0) { // Fork error
perror("Fork failed");
return 1;
} else if (pid == 0) { // Child process
printf("Hello");
} else { // Parent process
wait(); // Waits for the child to terminate
printf(" world”);
}
return 0;
}
5) (20 points) Consider the following empty memory blocks: 250, 500, 350, 750, and 125. A series of processes request memory in the
following sizes: 115, 450, 350, and 200. Using the Best Fit strategy:
a) Show which block is allocated to each process.
125 allocated for 115 remaining 10 memory units: 250, 500, 350, 750, 10
500 allocated for 450 remaining 50 memory units: 250, 50, 350, 750, 10
350 allocated for 350 remaining no memory units: 250, 50, 750, 10
250 allocated for 200 remaining 10 memory units: 50, 50, 750, 10
b) Show the final state of memory after all allocations: 50, 50, 750, 10

6) (10 points) Consider a process with a logical address space of 8 pages, each page size being 512 bytes. If the system has 64 frames in
physical memory, each of the same size as a page, calculate the number of bits required to represent the page number and the offset.

Number of bits for page number: 8 pages require log2(8) = 3 bits


Number of bits for page offset: 512 bytes require log2(512) = 9 bits

You might also like