solutions to the first midterm n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Solutions to the first midterm PowerPoint Presentation
Download Presentation
Solutions to the first midterm

Loading in 2 Seconds...

play fullscreen
1 / 37
renardo-brophy

Solutions to the first midterm - PowerPoint PPT Presentation

76 Views
Download Presentation
Solutions to the first midterm
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Solutions to the first midterm COSC 4330/6310 Summer 2012

  2. First question: True or false • Processes waiting for the CPU are in the waiting state.

  3. First question: True or false • Processes waiting for the CPU are in the waiting state. • FALSE, they are in the ready state

  4. First question: True or false • UNIX was the first system to be written in C.

  5. First question: True or false • UNIX was the first system to be written in C. • TRUE, it was designed to be portable(and C was specifically written for UNIX)

  6. First question: True or false • Memory protection is always implemented in hardware.

  7. First question: True or false • Memory protection is always implemented in hardware. • TRUE, any other solution would be too slow

  8. First question: True or false • execve() system calls are often followed by a fork() system call.

  9. First question: True or false • execve() system calls are often followed by a fork() system call. • FALSE, it is the other way around: fork() system calls are often followed by an execve() system call.

  10. First question: True or false • In a multiprogramming system, there can be many programs in the system but only one process .

  11. First question: True or false • In a multiprogramming system, there can be many programs in the system but only one process . • FALSE, there are many processes competing for one of the CPU cores

  12. First question: True or false • Most modern operating systems have a microkernel.

  13. First question: True or false • Most modern operating systems have a microkernel. • FALSE, microkernels are too slow

  14. Second question:Advantages and disadvantages • What is the major disadvantage ofmodular kernels over monolithic kernels?

  15. Second question:Advantages and disadvantages • What is the major disadvantage ofmodular kernels over monolithic kernels? • They make the kernel less robust.

  16. Second question:Advantages and disadvantages • What is the major advantage ofmodular kernels over monolithic kernels?

  17. Second question:Advantages and disadvantages • What is the major advantage ofmodular kernels over monolithic kernels? • They let users add functionality to the kernels like new file systems or device drivers for new devices

  18. Second question:Advantages and disadvantages • What is the major disadvantage ofCPUs that do not have a privileged mode?

  19. Second question:Advantages and disadvantages • What is the major disadvantage ofCPUs that do not have a privileged mode? • They cannot prevent user processes from executing I/O instructions

  20. Second question:Advantages and disadvantages • What is the major disadvantage of not having memory protection?

  21. Second question:Advantages and disadvantages • What is the major disadvantage of not having memory protection? • We cannot prevent user processes from tampering with the kernel (and other user processes)

  22. Second question:Advantages and disadvantages • What is the major advantage ofuser-level threads?

  23. Second question:Advantages and disadvantages • What is the major advantage ofuser-level threads? • They are portable and can run on kernels that do not support threads.

  24. Third question: I/O redirection • Complete the following fragment of code to ensure that the standard input of the process is redirected to the pipe mypipe. • int fd, mypipe[2];___________________________________________________close(mypipe[0]); close(mypipe[1]);

  25. Third question: I/O redirection • Complete the following fragment of code to ensure that the standard input of the process is redirected to the pipe mypipe. • int fd, mypipe[2];pipe(mypipe);close(0); dup(mypipe[0];close(mypipe[0]); close(mypipe[1]);

  26. Third question: I/O redirection • Complete the following fragment of code to ensure that the standard output of the process is redirected to the pipe mypipe. • int fd, mypipe[2];___________________________________________________close(mypipe[0]); close(mypipe[1]);

  27. Third question: I/O redirection • Complete the following fragment of code to ensure that the standard output of the process is redirected to the pipe mypipe. • int fd, mypipe[2];pipe(mypipe);close(1); dup(mypipe[1];close(mypipe[0]); close(mypipe[1]);

  28. Fourth question • How many lines of output will the following program print? (5 points) int main(){ if (fork() == 0) printf("Hello World!\n"); printf("Goodbye!\n") } // main • __________lines

  29. Fourth question • How many lines of output will the following program print? (5 points) int main(){ if (fork() == 0) printf("Hello World!\n"); printf("Goodbye!\n") } // main • Three lines

  30. Fifth question • Give an example of a real time process withsoft deadlines.

  31. Fifth question • Give an example of a real time process with soft deadlines. • A DVD player

  32. Sixth question • What is happening when a UNIX process issues a wait() system call and all its child processes have already terminated? • Will the process wait forever?

  33. Sixth question • What is happening when a UNIX process issues a wait() system call and all its child processes have already terminated? • Will the process wait forever? • NO, processes that have terminated but have not yet been waited for by their parents remain in the process table in the ZOMBIE state. • The waiting process returns immediately

  34. Seventh question • Which UNIX system call can we use to catch signals? What does it mean? Is it always possible?

  35. Seventh question • Which UNIX system call can we use to catch signals? What does it mean? Is it always possible? • signal(…) • signal specifies what the process should do when it receives a specific signal • No signal number 9 (SIGKIL) cannot be caught

  36. Eighth question • Why should we prevent users of a multi-user system from rebooting the OS from their own CD-ROM?

  37. Eighth question • Why should we prevent users of a multi-user system from rebooting the OS from their own CD-ROM? • User could reboot the system with an OS that will let do things they are not authorized to do