Revision en 2024
Revision en 2024
for(i=0;i<n;i++){
fork();
}
printf("Hello! \n");
return 0;
}
a. Draw 3 Gantt charts illustrating the execution of these processes using FCFS,
SJF, SRTF and RR (quantum = 2) scheduling.
b. What is the turnaround time of each process for each of the scheduling
algorithms in part a?
3. Many CPU-scheduling algorithms are parameterized. For example, the RR
algorithm requires a parameter to indicate the time slice. Multilevel feedback
queues require parameters to define the number of queues, the scheduling
algorithms for each queue, the criteria used to move processes between queues,
and so on. These algorithms are thus really sets of algorithms (for example,
the set of RR algorithms for all time slices, and so on). One set of algorithms
may include another (for example, the FCFS algorithm is the RR algorithm with
an infinite time quantum). What (if any) relation holds between the following
pairs of algorithm sets?
a. Priority and SJF
d. RR and SJF
4. A computer provides each process with 32768 bytes of address space divided
into pages of 4096 bytes.
a. How many page frames could a process be allocated?
b. A particular program has 3 segments: a text size of 11770 bytes, a data size of
10284 bytes, and a stack size of 9786 bytes. Will this program fit in the
address space?
c. If the page size were 512 bytes, would it fit?
Remember that a page may not contain parts of two different segments.
5. Given the following reference string:
021301401234
a. Show page faults occur during the processing of the reference scheme with
LRU and FIFO, OPTIMAL, CLOCK? Each process is allocated 3 empty page
frames.
b. Estimate the hit ratio for LRU policies in a pure demand paging system if the
TLB could contains 3 entries. Then compute the effective access time,
suppose TLB lookup takes 5 nano sec, and memory access time is 100 nano
sec.
6. Consider a system where the virtual memory page size is 2K (2048 bytes), and
main memory consists of 4 page frames. Now consider a process which requires
8 pages of storage. At some point during its execution, the page table is as shown
below:
7 Yes 2
7. Given the following code:
1: int main(int argc, char *argv[]) {
3: int a, e;
5: a = 10;
6: if (fork() == 0) {
7: a = a *2 ;
8: if (fork() == 0) {
9: a = a +1;
10: exit(2);
11: }
12: printf(" %d \n", a);
13: exit(1);
14: }
15: wait(&e);
16: printf("a: %d;e : %d \n", a, WEXITSTATUS(e));
17: return(0);
18: }
Give the number of processes generated when running this program and the
content display onto the screen for each process.
8. Choose the correct state transition.
a. new - ready - running - waiting - terminated
b. new - waiting - ready - running - terminated
c. new - ready - waiting - ready - running - terminated
d. new - ready - running - waiting - ready - running – terminated
P0 P1
….. …..
while (turn != 0) { } /* Do while (turn != 1) { } /* Do nothing
nothing and wait. */ and wait. */
Critical Section /* . . . */ Critical Section /* . . . */
turn = 0; turn = 1;
…. ….
For P1, 0 is replaced by 1. Does this solution satisfy the mutual exclusion?
The code for P10 is identical except that it uses V(mutex) instead of P(mutex).
V(mutex)
{Critical Section}
V(mutex)
What is the largest number of processes that can be inside the critical section at any
moment (the mutex being initialized to 1)?
12. Given the following code for P[i], i=0..3, initialize m[i]=1
wait (m[i]); wait(m[(i+1) mode 4]);
//critical section
14. Consider a computer system with a 32-bit logical address and 4-KB page size.
The system supports up to 512 MB of physical memory. How many entries are
there in each of the following?
a. A conventional, single-level page table
b. An inverted page table dựa trên số frames
15. Consider the page table for a system with 12-bit virtual and physical addresses
and 256-byte pages.
The list of free page frames is D, E, F (that is, D is at the head of the list, E is
second, and F is last). A dash for a page frame indicates that the page is not in
memory.
Convert the following virtual addresses to their equivalent physical addresses
in hexadecimal. All numbers are given in hexadecimal.
• 9EF
• 111
• 700
• 0FF
17. Suppose a computer has a file system for a 256MB disk, where each disk block
is 1MB.
a. If the OS for this computer uses a FAT, what is the smallest amount of
memory that could possibly be used for the FAT (assuming the entire FAT
is in memory)? Explain.
b. Given the following information:
0 0 8
1 1 3
2 2 6
3 3 2
4 4 1
5 5 end-of-file
6 6 5
7 7 4
8 8 7
….. …..
20. Suppose that a disk drive has 2000 cylinders, numbered 0 to 1999. The drive is
currently serving a request at cylinder 950, and the previous request was at
cylinder 15. The queue of pending requests, in FIFO order, is: 86,1470, 913,
1774, 948, 1509, 1022,1750,130. Starting from the current head position, what
is the total distance (number of cylinders) that the disk arm moves to satisfy all
the pending requests for each of the following disk-scheduling algorithms
(FCFS, SSTF, SCAN, C-SCAN, LOOK, C-LOOK) ?