Question |
Max. |
Current |
True/False |
10 pts. |
|
Short Questions 1-5 |
15 pts. |
|
Short Questions 6-10 |
15 pts. |
|
11, |
10 pts. |
|
12. |
10 pts. |
|
13. |
15 pts. |
|
14. |
15 pts. |
|
15. |
10 pts |
|
Total: |
2. (3 pts.) Explain the advantages and disadvantages of choosing a
small quantum.
3. (3 pts.) Explain how Multi-Level Feedback-Queue Scheduling works.
4. (3 pts.) Explain in what situations the user time + kernel time
is larger than the wall-clock time.
5. (3 pts.) Explain the advantages and disadvantages of
Preemptive Scheduling
6. (3 pts.) Enumerate the memory sections of a program and explain
what they store.
7. (3 pts.) What are the roles of the Loader
8. (3 pts.) What are the advantages and disadvantages of using threads vs. using processes?
9. (3 pts.) What is the problem of having long critical sections in a
multiprocessor machine?
10. (3 pts.) Explain what is a race condition and why they are
difficult to reproduce.
11. (10 pts.) Implement the function char
*strrchr(char *s, int c); that returns a pointer to the last
occurrence of c or NULL if c is not part of the string. |
char *strrchr(char *s, int c) |
12. (10 pts.) Implement the class Array4D of type double that creates a 4D array of 4 dimensions m x n x r x q as indicated in the constructor. Also implement the function getElementAt and setElementAt that gets and sets the element at this location. Base your implementation in the array of pointers to rows that we covered in class. |
class Array4D { // Add any variables you need public: Array4D( int m, int n, int r, int q); double getElementAt( int m, int n, int r, q); void setElementAt( int m, int n, int r, q); Array4D::Array4D( int m, int n, int r, int q) {
} double Array4D::getElementAt( int i, int j, int k, int q) {
} void
|
14. (15 pts.) Write a class AlertTemp that implements two methods: void listenTemp(int minTemp, int maxTemp) and void setCurrentTemp( int currentTemp). A thread calling the function listenTemp will block until there is another thread calling setCurrentTemp(currentTemp) where minTemp <=curentTemp<=maxTemp. A thread calling setCurrentTemp(currentTemp) may wakeup multiple threads calling void listenTemp(int minTemp, int maxTemp) if curentTemp matches these calls. If the call to setCurrentTemp(currentTemp) does not match any of the listenTemp calls or no thread is waiting , the setCurrentTemp call is ignored. Note: Use condition variables. |
|
15. (10 pts) Implement a class SynchronizedStack that
implements a stack that stores elements of type int. The methods push and pop. If pop is called
and the stack is empty it will block until the stack is not
empty. push will
block if the stack is full and will continue when the stack has space
to perform the operation. The constructor initializes the stack
with the maximum size and any other necessary variables. |
|