+ All Categories
Home > Documents > Solutions to the first midterm COSC 4330/6310 Summer 2012.

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

Date post: 29-Dec-2015
Category:
Upload: valentine-morton
View: 218 times
Download: 2 times
Share this document with a friend
Popular Tags:
37
Solutions to the Solutions to the first midterm first midterm COSC 4330/6310 COSC 4330/6310 Summer 2012 Summer 2012
Transcript
Page 1: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Solutions to the first Solutions to the first midtermmidterm

COSC 4330/6310COSC 4330/6310

Summer 2012Summer 2012

Page 2: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

Processes waiting for the CPU are in the Processes waiting for the CPU are in the waitingwaiting state. state.

Page 3: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

Processes waiting for the CPU are in the Processes waiting for the CPU are in the waitingwaiting state. state.

FALSEFALSE, they are in the , they are in the ready stateready state

Page 4: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

UNIX was the first system to be written in CUNIX was the first system to be written in C..

Page 5: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

UNIX was the first system to be written in CUNIX was the first system to be written in C..

TRUETRUE, it was designed to be portable, it was designed to be portable(and C was specifically written for UNIX)(and C was specifically written for UNIX)

Page 6: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

Memory protection is always Memory protection is always implemented in hardware.implemented in hardware.

Page 7: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

Memory protection is always implemented Memory protection is always implemented in hardware.in hardware.

TRUE, any other solution would be too slowTRUE, any other solution would be too slow

Page 8: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

execve()execve() system calls are often followed by system calls are often followed by a a fork()fork() system call. system call.

Page 9: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

execve()execve() system calls are often followed by system calls are often followed by a a fork()fork() system call. system call.

FALSE, it is the other way around:FALSE, it is the other way around:

fork()fork() system calls are often followed by system calls are often followed by an an execve() execve() system call. system call.

Page 10: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

In a In a multiprogramming systemmultiprogramming system, there can , there can be be many programsmany programs in the system but only in the system but only one processone process . .

Page 11: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

In a In a multiprogramming systemmultiprogramming system, there can , there can be be many programsmany programs in the system but only in the system but only one processone process . .

FALSEFALSE, there are many processes , there are many processes competing for one of the CPU cores competing for one of the CPU cores

Page 12: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

Most modern operating systems have a Most modern operating systems have a microkernel.microkernel.

Page 13: Solutions to the first midterm COSC 4330/6310 Summer 2012.

First question: True or falseFirst question: True or false

Most modern operating systems have a Most modern operating systems have a microkernel.microkernel.

FALSEFALSE, microkernels are too slow , microkernels are too slow

Page 14: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Second question:Second question:Advantages and disadvantagesAdvantages and disadvantages

What is the major disadvantage ofWhat is the major disadvantage of modular modular kernels kernels overover monolithic kernels monolithic kernels??

Page 15: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Second question:Second question:Advantages and disadvantagesAdvantages and disadvantages

What is the major disadvantage ofWhat is the major disadvantage of modular modular kernels kernels overover monolithic kernels monolithic kernels??

They make the kernel less robust. They make the kernel less robust.

Page 16: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Second question:Second question:Advantages and disadvantagesAdvantages and disadvantages

What is the major advantage ofWhat is the major advantage of modular modular kernels kernels overover monolithic kernels monolithic kernels??

Page 17: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Second question:Second question:Advantages and disadvantagesAdvantages and disadvantages

What is the major advantage ofWhat is the major advantage of modular modular kernels kernels overover monolithic kernels monolithic kernels??

They let users add functionality to the kernels They let users add functionality to the kernels like new file systems or device drivers for like new file systems or device drivers for new devices new devices

Page 18: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Second question:Second question:Advantages and disadvantagesAdvantages and disadvantages

What is the major disadvantage ofWhat is the major disadvantage of CPUs that CPUs that do do notnot have a have a privileged modeprivileged mode??

Page 19: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Second question:Second question:Advantages and disadvantagesAdvantages and disadvantages

What is the major disadvantage ofWhat is the major disadvantage of CPUs that CPUs that do do notnot have a have a privileged modeprivileged mode??

They cannot prevent user processes from They cannot prevent user processes from executing I/O instructions executing I/O instructions

Page 20: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Second question:Second question:Advantages and disadvantagesAdvantages and disadvantages

What is the major disadvantage of What is the major disadvantage of not not having memory protectionhaving memory protection??

Page 21: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Second question:Second question:Advantages and disadvantagesAdvantages and disadvantages

What is the major disadvantage of What is the major disadvantage of not not having memory protectionhaving memory protection??

We cannot prevent user processes from We cannot prevent user processes from tampering with the kernel (and other user tampering with the kernel (and other user processes) processes)

Page 22: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Second question:Second question:Advantages and disadvantagesAdvantages and disadvantages

What is the major advantage ofWhat is the major advantage of user-level user-level threadsthreads??

Page 23: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Second question:Second question:Advantages and disadvantagesAdvantages and disadvantages

What is the major advantage ofWhat is the major advantage of user-level user-level threadsthreads??

They are portable and can run on kernels They are portable and can run on kernels that do not support threads.that do not support threads.

Page 24: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Third question: I/O redirectionThird question: I/O redirection

Complete the following fragment of code to Complete the following fragment of code to ensure that the ensure that the standard inputstandard input of the of the process is redirected to the pipe process is redirected to the pipe mypipemypipe. .

int fd, mypipe[2];int fd, mypipe[2];______________________________________________________________________________________________________close(mypipe[0]); close(mypipe[1]);close(mypipe[0]); close(mypipe[1]);

Page 25: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Third question: I/O redirectionThird question: I/O redirection

Complete the following fragment of code to Complete the following fragment of code to ensure that the ensure that the standard inputstandard input of the of the process is redirected to the pipe process is redirected to the pipe mypipemypipe. .

int fd, mypipe[2];int fd, mypipe[2];pipe(mypipe);pipe(mypipe);close(0); dup(mypipe[0];close(0); dup(mypipe[0];close(mypipe[0]); close(mypipe[1]);close(mypipe[0]); close(mypipe[1]);

Page 26: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Third question: I/O redirectionThird question: I/O redirection

Complete the following fragment of code to Complete the following fragment of code to ensure that the ensure that the standard outputstandard output of the of the process is redirected to the pipe process is redirected to the pipe mypipemypipe. .

int fd, mypipe[2];int fd, mypipe[2];______________________________________________________________________________________________________close(mypipe[0]); close(mypipe[1]);close(mypipe[0]); close(mypipe[1]);

Page 27: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Third question: I/O redirectionThird question: I/O redirection

Complete the following fragment of code to Complete the following fragment of code to ensure that the ensure that the standard outputstandard output of the of the process is redirected to the pipe process is redirected to the pipe mypipemypipe. .

int fd, mypipe[2];int fd, mypipe[2];pipe(mypipe);pipe(mypipe);close(1); dup(mypipe[1];close(1); dup(mypipe[1];close(mypipe[0]); close(mypipe[1]);close(mypipe[0]); close(mypipe[1]);

Page 28: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Fourth questionFourth question How many lines of output will the following program How many lines of output will the following program

print? (5 points)print? (5 points)

int main(){int main(){

if (fork() == 0)if (fork() == 0)

printf("Hello World!\n");printf("Hello World!\n");

printf("Goodbye!\n")printf("Goodbye!\n")

} // main} // main

__________lines__________lines

Page 29: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Fourth questionFourth question How many lines of output will the following program How many lines of output will the following program

print? (5 points)print? (5 points)

int main(){int main(){

if (fork() == 0)if (fork() == 0)

printf("Hello World!\n");printf("Hello World!\n");

printf("Goodbye!\n")printf("Goodbye!\n")

} // main} // main

Three linesThree lines

Page 30: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Fifth questionFifth question

Give an example of a real time process withGive an example of a real time process with soft deadlinessoft deadlines..

Page 31: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Fifth questionFifth question

Give an example of a real time process Give an example of a real time process with with soft deadlinessoft deadlines..

A DVD playerA DVD player

Page 32: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Sixth questionSixth question

What is happening when a UNIX process What is happening when a UNIX process issues a wait() system call and all its child issues a wait() system call and all its child processes have already terminated?processes have already terminated?

Will the process wait forever? Will the process wait forever?

Page 33: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Sixth questionSixth question What is happening when a UNIX process issues What is happening when a UNIX process issues

a wait() system call and all its child processes a wait() system call and all its child processes have already terminated?have already terminated?

Will the process wait forever? Will the process wait forever?

NO, processes that have terminated but have not NO, processes that have terminated but have not yet been waited for by their parents remain in the yet been waited for by their parents remain in the process table in the ZOMBIE state.process table in the ZOMBIE state.

The waiting process returns immediatelyThe waiting process returns immediately

Page 34: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Seventh questionSeventh question

Which UNIX system call can we use to Which UNIX system call can we use to catch signals? What does it mean? Is it catch signals? What does it mean? Is it always possible? always possible?

Page 35: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Seventh questionSeventh question Which UNIX system call can we use to Which UNIX system call can we use to

catch signals? What does it mean? Is it catch signals? What does it mean? Is it always possible?always possible?

signal(…)signal(…) signal specifies what the process should do signal specifies what the process should do

when it receives a specific signalwhen it receives a specific signal No signal number 9 (SIGKIL) cannot be No signal number 9 (SIGKIL) cannot be

caught caught

Page 36: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Eighth questionEighth question

Why should we Why should we prevent prevent users of a multi-users of a multi-user system from user system from rebootingrebooting the OS from the OS from their own CD-ROM?their own CD-ROM?

Page 37: Solutions to the first midterm COSC 4330/6310 Summer 2012.

Eighth questionEighth question

Why should we Why should we prevent prevent users of a multi-users of a multi-user system from user system from rebootingrebooting the OS from the OS from their own CD-ROM?their own CD-ROM?

User could reboot the system with an OS User could reboot the system with an OS that will let do things they are not authorized that will let do things they are not authorized to doto do


Recommended