$29.99
CS3510: Operating Systems I
Instructions for submission:
1. You must submit your final answer copy as pdf.
2. You should avoid submitting scan copies of hand-written notes. Only if you wish to attach any figure, you can attach the scans of the figures in your pdf.
1. System calls are executed in the kernel-mode (supervisor or privileged mode) by the Operating System to satisfy some request on behalf of the normal user. In this case, how does the OS ensure safety of the system when it is executing a system call in the privileged mode on the behalf of the user. As you might recall normally all the user programs run in user-mode for greater security? (4 pts)
2. For each of the following system calls, give a condition that causes it to fail: fork , exec. (4 pts)
3. Virtual machines have become very popular for a variety of reasons. Nevertheless, they have some downsides. Name atleast one such disadvantage. (3 pts)
4. Using the program shown in Figure below, explain what the output will be at lines X and Y. Please justify your answer. (5 pts)
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h> #define SIZE 5 int nums[SIZE] = { 0,1,2,3,4 } ;
int main()
{
int i; pid t pid;
// Initialize the values for (i = 0; i < SIZE; i++) { nums[i] = 1;
}
pid = fork(); if (pid == 0) { for (i = 0; i < SIZE; i++) { nums[i] += -i;
printf("CHILD: %d %d", i, nums[i]); /* LINE X */ }
}
1
else if (pid > 0) {
wait(NULL);
for (i = 0; i < SIZE; i++) nums[i] *= -i;
printf("PARENT: %d %d", i,nums[i]); /* LINE Y */ }
}
return 0;
}
5. Figure 3.5 (page 113 of the book) suggests that a process can only be in one event queue at a time. Is it possible that you would want to allow a process to wait on more than one event at the same time? Provide an example. (5 pts)
2