Question |
Max. |
Current |
True/False |
10 pts. |
|
Short Questions 1-5 |
15 pts. |
|
Short Questions 5-10 |
15 pts. |
|
11, |
10 pts. |
|
12. |
10 pts. |
|
13. |
20 pts. |
|
14. |
10 pts. |
|
15. |
10 pts |
|
Total: |
2. (3 pts.) Give the advantages and disadvantages of user threads v.s. kernel threads.
3. (3 pts.) If in the code for the spinlock we remove the yield inside the loop, a) Will the spinlock work? b) If it works, explain what possible problems it will encounter. If it does not work explain why it will not work.
4. (3 pts.) Explain the checks that the kernel does during the system call write(fd, buff, n)
5. (3 pts.) Enumerate the problems that you may have calling free(ptr)
6. (3 pts.) Explain why the quantum length has to be longer than the average
CPU burst.
7. (3 pts.) Explain how the average CPU burst length of a process affects
the scheduling priority of the process in operating systems like Solaris.
8. (3 pts.) Write the pseudocode for sema_post(sem) and sema_wait(sem)
9. (3 pts.) Explain why malloc returns addresses that are aligned to 8 byte
boundaries (multiple of 8).
10. (3 pts.) Explain the advantages and disadvantages of having the OS
kernel running in kernel mode and the user programs running in user mode.
11. (10 pts.) Implement the function reverse(s) that reverses
a string. The resulting string is left in s. Do not use any of the string
functions. |
void reverse(const char * s) |
12. (10 pts.) Write the method reverseList() that reverses the order a single-linked list. Write the implementation below. |
|
13. (20 pts.) Write a program "lssort" that implements the
command "ls -laR dir | sort > out". The program should not return until
the command finishes. "dir" and "out" are passed as arguments to the program.
Example of the usage is "lssort /etc outfile",. Do error checking. |
|
14. (10 pts.) Write a class SynchronizedList that implements
two methods: Add(int val) and int Remove(). The procedure Add(int val)
appends an element at the end of the list. The method Remove() removes the
element at the head of the list and returns its value.Only a maximum of 10
elements can be in the list at any time. The method Remove() will block until
there is an item to remove. The method Add will block if there are already
10 elements in the list. |
struct ListNode {
|
15. (10 pts) Write a class Alert that has procedures waitAlert(int
maxVal) and setValue(val). The method waitAlert(int maxVal) will block until
there is a call to setValue(val) where val > maxVal. Multiple threads
may be calling waitAlert(int maxVal) and multiple threads may wakeup at once. setValue(val)
may wake up other threads but it will never block. |
|