CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill...

15
[Type the company name] CS604 Operating Systems Midterm 2013 1 A computer system can be divided roughly into four components: The software, the operating system, the application programs and the users The hardware, the operating system, the application programs and the users The hardware, the operating system, the application programs and the emails The hardware, the database system, the application programs and the users 2. We use function -------------------to create a thread fork() thread() (pg 71) mkfifo() open() 3. The priorities of processes in the ----------Group remain fixed whereas the priorities of processes in the -----------Group are recalculated every second. Kernel, Kernel User, Kernel User, User Kernel, User (pg 93) 1Command-line interpreter is often known as the -------- register shell (pg 16) kernel timer 2. You can display all of the signals supported by your system, along with their numbers, by using the -----------command <Ctrl-A> fg

Transcript of CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill...

Page 1: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

1

A computer system can be divided roughly into four components: The software, the operating system, the application programs and the users The hardware, the operating system, the application programs and the users

The hardware, the operating system, the application programs and the emails The hardware, the database system, the application programs and the users 2. We use function -------------------to create a thread fork() thread() (pg 71)

mkfifo() open() 3. The priorities of processes in the ----------Group remain fixed whereas the priorities of processes in the -----------Group are recalculated every second. Kernel, Kernel User, Kernel User, User Kernel, User (pg 93)

1Command-line interpreter is often known as the -------- register shell (pg 16)

kernel timer 2. You can display all of the signals supported by your system, along with their numbers, by using the -----------command <Ctrl-A> fg

Page 2: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

2

jobs kill –l (pg 69)

4. The section of code implementing the request that each process must first request permission to enter its critical section is called the ------------- Critical Section (CS) Entry Section (ES) (pg 101)

Leave/Exit Section (LS). Remainder Section (RS). 5. OS helps manages the following except Application software Bus speed of the system

Memory Virtual memory 6. The critical section problem can be solved by the following except Software based solution Firmware based solution (pg 101)

Operating system based solution Hardware based solution 7. __________ commands in Linux is used to copy file ls cp (pg 30)

mv mkdir 8. In Unix/ Linux, by default the standard input file is attached to the ___________ Mouse Keyboard (pg 55)

Light pen Joystick 9. Which one of the following is the correct syntax to copy file1 to file2? cp file2, file1 cp file1/file2 cp file2 file1 cp file1 file2 (pg 30)

10. Which one of the following indicates end of the file in a read ( ) system call? -1

0 1 2 11. Which of the following command is used to read data from file named academics? con < academics cat < academics (page 58)

socket > academics ran > academics 12. The __________ view is a program that acts as an intermediary between a user of a computer and the computer hardware, and makes the computer system convenient to use. Top-down (pg 6)

Page 3: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

3

Bottom-up External Internal 13. ________threads are supported directly by the operating system. Kernel (pg 73)

Functional Non-functional User 14. In __________model, there is a kernel thread for every user thread. One-to-one (pg 74)

Many –to-one One-to-many Many-to-many 15. While two processes in execution, only one can be in critical section at a time , this requirement is named as __________. Race condition Mutual exclusion (page 101

Progress Bounded waiting 16. A binary semaphore________. has the values one or zero (page 117)

is essential to binary computers is a deadlock scheme is a preemption scheme 17. A ------------process produces information that is consumed by a -----------process. Consumer, Producer Producer, Consumer (pg 44)

Customer, Purchaser Merchandiser, Consumer 18. Blocking is considered ___________ and Non-blocking is considered _____________ . Synchronous , Asynchronous (pg 47)

Synchronous , Asynchronous Direct , Indirect Zero capacity , Bounded capacity 19. -------------------- are used by shell commands to pass data from one shell pipeline to another, without creating temporary files. Pipes Message queues BSD sockets FIFOs (pg 61)

20. mkfifo() is a (an) ------------------ . System call Library call (pg 58)

Interrupt Signal 1 A ----------- is a multi-user, multi-process, and interactive system

Page 4: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

4

Batch systems Single-user system Time-sharing systems (pg 9)

Multi programmed systems 2. You can display all of the signals supported by your system, along with their numbers, by using the -----------command <Ctrl-A> fg jobs kill –l (pg 69)

CS604 Operating Systems 1. The priorities of processes in the ----------Group remain fixed whereas the priorities of processes in the -----------Group are recalculated every second. Kernel, Kernel User, Kernel User, User Kernel, User (pg 93)

2. Preemptive scheme of Short job first scheduling is known as ------- First Come First Serve Scheduling Priority Scheduling Round-Robin Scheduling Shortest-Remaining-Time-First (pg 85)

3. In Linux directory structure, there is ___________ root directory. 1 (pg 26)

2 3 4 4. Linux uses ___________ directory to store system configuration files. /bin /dev /boot /etc (pg 26)

5. Process synchronization is a process of helping processes to _________________ update the shared data simultaneously update the shared data and resources in an orderly fashion (g 98)

not to update the shared data or memory access data and memory at first come first serve basis 6. All ------------ within a process share the same address space Threads (pg 70)

Processes CPU burst IO Burst 7. …………………….. provides basic computing resources. Application programs Operating System

Page 5: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

5

Hardware (pg 4)

Users 8. The systems that control scientific experiments, medical imaging systems, industrial control systems and certain display systems are examples of ………………….. systems. Real Time system (pg 9)

Batch Multi programmed Time-sharing system 9. A named pipe is a pipe whose access point is a file kept on the file system called as………………………. None of the given All of the given (pg 59)

Named FIFO FIFO 10. A new process can be created by using Fork System Call (pg 39)

Trap Signal Interrupt 11. Which of the following command is used to read data from file named academics? con < academics cat < academics (page 58)

socket > academics ran > academics 12. “No resource can be forcibly removed from a process holding it” best describes which one of the following conditions? Mutual Exclusion (page 131)

Hold and wait Starvation No preemption 13. ________threads are supported directly by the operating system. Kernel (pg 73)

Functional Non-functional User 14. ________threads are implemented by a thread library at the user level. Kernel User (pg 73)

Functional Non-functional 15. A ______________ is a piece of code in a cooperating process in which the process may update shared data (variable, file, database, etc.). critical section (pg 100)

critical region monitor semaphore

Page 6: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

6

16. A ------------process produces information that is consumed by a -----------process. Consumer, Producer Producer, Consumer (pg 44)

Customer, Purchaser Merchandiser, Consumer 17. The wait () system call suspends the calling process until one of the immediate children _______________ or until a child that is being traced stops because it has hit an event of interest. Processes Terminates (pg 42)

Sleeps Executes 18. Blocking is considered ___________ and Non-blocking is considered _____________ . Synchronous , Asynchronous (pg 47)

Asynchronous , Synchronous Direct , Indirect Zero capacity , Bounded capacity 19. In client-server applications, which of the following are used to pass data between a server process and client processes? FIFOs (pg 61)

Message queues BSD sockets Pipes 20. mkfifo() is a (an) ------------------ . System call Library call (pg 58)

Interrupt Signal CS604 Operating Systems

1.In Linux directory structure, there is ___________ root directory. 1 (pg 26)

2 3 4 2. Shared libraries and kernel modules are stored in _____________ directory /bin /dev /boot /lib (pg 26)

3. __________________ is a software based solution to the synchronization problem. Bakery algorithm TSL instruction Semaphore(page 111)

Monitors 4. In a Multilevel Queue, the foreground queue has -------- scheduling algorithm and background queue has -------------- scheduling algorithm

Page 7: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

7

First Come First Serve, Round-Robin Round-Robin, First Come First Serve (pg 91)

Round-Robin, Round-Robin First Come First Serve, First Come First Serve 5. Time from submission to completion of process is called ------------ Response Time (pg 83)

Throughput Waiting Time Turnaround Time: 6. The creating process is called a--------------- process while the new processes are called the -------------- of that process None of the given options Parent, children (pg 38)

Zombie, single Children, parent 7. Taking the CPU from one process and giving the cpu to another process is termed as Context Switching (pg 34)

Dispatching Swapping Tracking 8. Using _________system call, we can create a new process in Unix. Fork (pg 39)

exec wait exit 9. Which type of operating system guarantees that critical tasks must be completed on time? Timesharing system Multitasking system Batch system Realtime system (pg 10)

10. Which of the following is used to show the end of file in unix? Ctrl+D

Ctrl+A Ctrl+O Ctrl+E 11. In a multithreaded model, Which one of the following provides true concurrency? Many-to-one One-to-one (pg 74)

Many-to-many One-to-many 12. “No resource can be forcibly removed from a process holding it” best describes which one of the following conditions? Mutual Exclusion Repeated

Hold and wait Starvation

Page 8: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

8

No preemption 13. The __________ view is a program that acts as an intermediary between a user of a computer and the computer hardware, and makes the computer system convenient to use. Top-down (pg 6)

Bottom-up External Internal 14. ___________ and __________ CPU registers are specifically designed to provide memory protection by limiting access to a process with in its address space. Counter, add Base, limit (pg13)

Program counter, accumulator Buffer, data register 15. A time interval when a process uses I/O devices only is called __________. CPU burst I/O burst (Not sure)

Scheduling Context switching 16. Under _________scheduling, once the CPU has been allocated to a process, the process keeps the CPU until either it switches to the waiting state, finishes its CPU burst, or terminates. Short-term scheduler Preemptive Non-preemptive (pg 82)

Both preemptive and non- preemptive 17. The non-critical section code in any critical section problem is termed as ____________. Critical Section Entry Section Leave/Exit Section Remainder Section (pg 101)

18. N-process critical section problem can be solved by using ______________. The bakery algorithm (page 105)

Deterministic modeling Analytic Evaluation TestAndSet instruction 19. In direct communication, link is associated with exactly_______pair(s) of communicating processes. Four Two (pg 47)

One Three 20. In Unix/Linux client server process communication, server process runs in the background by terminating its command line with --------------. & (pg 65)

@

Page 9: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

9

% $ CS604 Operating Systems 1.Preemptive ----------------scheduling is sometimes called shortest-remaining-time-first scheduling. First-Come-First-Served (FCFS) Round-Robin Sorted Job First (SJF) (pg 85)

Priority 2. The priorities of processes in the ----------Group remain fixed whereas the priorities of processes in the -----------Group are recalculated every second. Kernel, Kernel User, Kernel User, User Kernel, User (pg 93)

3. Each thread has its own --------------- Process ID (PID) Address space Thread ID (TID) (page 70) Open file descriptors 5. Files that start with a -------- in UNIX/Linux directory structure are known as hidden files . . (dot) (pg 28)

# ( hash ) / (slash) ~ (tilt) 6. You can compile yours program in a UNIX/LINUX system by the ----------- command $rm $cp $mv Gcc (page 31)

7. A process terminates by calling the -----------system call. Wait Fork exec exit (pg 39)

8. __________ scheduler selects the process from the job pool and put them in main memory. Long term (pg 36)

Short term Medium term Swapper 9. Which of the following command is used to read data from file named academics? con < academics cat < academics (Repeated) socket > academics ran > academics

Page 10: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

10

10. Semaphore can be used for solving __________. Wait & signal Deadlock Synchronization (page 111)

Priority 11. In ________________, user does not get to interact with his/her jobs and jobs having similar needs are executed in groups at the same time, one after the other. Batch systems (page 7)

Multi programmed systems Single-user system Time-sharing systems 12. In __________ model, many user-level threads are supported per kernel thread. One-to-one Many –to-one Many-to-many (pg73)

One-to-many 13. Command-line interpreter is also called __________ in some operating systems. Kernel Shell (pg 16)

Signal API 14. A time interval when a process uses CPU only is called _____________. Scheduling I/O burst CPU burst

Dispatch latency 15. A time interval when a process uses I/O devices only is called __________. CPU burst I/O burst

Scheduling Context switching 16. The process that satisfies all three requirements of critical section problem is called _________. Algorithm 1 Algorithm 2 Algorithm 3 (page 104)

Algorithm N 17. The TSL (TestAndSet instruction) which is the hardware solution to synchronization problem does not satisfy the ________ condition, hence not considered to be a good solution. Progress Bounded waiting (page 109)

Mutual exclusion No preemption 18.The Swap instruction which is the hardware solution to synchronization problem does not satisfy the ________ condition, hence not considered to be a good solution. Progress

Page 11: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

11

Bounded waiting (page 109)

Mutual exclusion No preemption 19. A ---------process is a process that has terminated but whose exit status has not yet been received by its parent process or by init. Parent Zombie (page 42)

Child Fork 20. Blocking is considered ___________ and Non-blocking is considered _____________ . Synchronous , Asynchronous (pg 47)

Asynchronous , Synchronous Direct , Indirect Zero capacity , Bounded capacity

21. Differentiate Entry section and Remainder section.02

Answer: The section of code implementing this request is called the entry section. The remaining code is the remainder section.

When a process executes code that manipulates shared data (or resource), we say that the process is in its critical section (for that shared data). The execution of critical sections must be mutually exclusive: at any time, only one process is allowed to execute in its critical section (even with multiple processors). So each process must first request permission to enter its critical section. The section of code implementing this request is called the entry section. The remaining code is the remainder section. 22. Suppose there is a thread mapping model used to map user-level threads to

kernel-level threads. Here in this model, there exist many kernel-level threads that

support a number of user-level threads and concurrencies in between these threads.

Suggest the name of the model described above. 02

Answer: One-to-One: In this model, there is a kernel thread for every user thread Thus, this model provides true concurrency. This means that a process does not block when a thread makes a system call. The main disadvantage of this model is the overhead of creating a kernel thread per user thread. Examples of these threads are WindowsNT, Windows 2000, and OS/2.

Page 12: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

12

23. Threads play impotant role during the exection of processes. You have to identify

how does a thread operate in the same way as that of a process? Mention at least 2

similarities between a thread and a process.03 Answer: Similarities between thread and process.

• Share cpu • sequential execution • create child • If one thread is blocked then the next will be start to run like process

21. Process can run either as background process or as foreground process. If there

is a process which is in the suspended state and working in background, you wanted

to display the status of suspended and background process in a UNIX/LINUX shell.

Which command will you use?02

Answer: Moving a process into foreground: fg [%job_id] where, job_id is the job ID (not process ID) of the suspended or background process. If %job_id is omitted, the current job is assumed. Moving a process into background: bg [%job_id] If %job_id is omitted the current job is assumed. (pg 68)

22. Give at least two real world example that illustrate critical section problem.02

Answer: Critical Section A piece of code in a cooperating process in which the process may update shared data (variable, file, database, etc.). Concurrent transactions in a bank or in an airline reservation (or travel agent) office are a couple of other examples that illustrates the critical section problem.

23. With respect to UNIX System V scheduling algorithm, Sort the Kernel group

activities in decreasing order of priority as given below:

• Character I/O device control processes

• File manipulation

• Swapper

• User processes

• Block I/O device control processes03

Answer: • Swapper • Block I/O device control processes • File manipulation • Character I/O device control processes • User processes

24. Process can run either as background process or as foreground process. If the

process is running in background and you wanted to resume a process in a

UNIX/LINUX shell. Which command will you use for it? Write its syntax used in

UNIX/LINUX and explains each part of it.03

Answer: Moving a process into foreground: fg [%job_id]

Page 13: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

13

where, job_id is the job ID (not process ID) of the suspended or background process. If %job_id is omitted, the current job is assumed. Moving a process into background: bg [%job_id] If %job_id is omitted the current job is assumed. (pg 68)

25. Let us consider a situation in which we want to communicate between unrelated

processes on the same system (not on different systems). In UNIX/Linux, which IPC

tool will be used in this situation and why?05

Answer: Named pipe (FIFO): FIFOs (also known as named pipes) are used for communication between related or unrelated processes on a UNIX/Linux system. We continue to discuss the API for using FIFOs for IPC between UNIX/Linux processes. We call these processes client and server. The server process creates two FIFOs, FIFO1 and FIFO2, and opens FIFO1 for reading and FIFO2 for writing. The client process opens FIFO1 for writing and FIFO2 for reading. The client process writes a message to the server process and waits for a response from the server process. The server process reads the message sent by the client process and displays it on the monitor screen. It then sends a message to the client through FIFO2, which the client reads and displays on the monitor screen. The server process then closes the two FIFOs and terminates. The client, after displaying server’s message, deletes the two FIFOs and terminates. 26. What do you think that which “critical section problem” is actually depicting and

in how many ways its solution can be categorized?05

Answer: When a process executes code that manipulates shared data (or resource), we say that the process is in its critical section (for that shared data). The execution of critical sections must be mutually exclusive: at any time, only one process is allowed to execute in its critical section (even with multiple processors). So each process must first request permission to enter its critical section. There can be three kinds of solution to the critical section problem:

• Software based solutions • Hardware based solutions

Operating system based solution

21. Which term is best suited for a situation in which a process is in its critical

section, any other process that tries to enter its critical section must loop

continuously in the entry code?02 Answer: This continual looping is clearly a problem in a real multiprogramming system, where a single CPU is shared among many processes. Busy waiting wastes CPU cycles that some other process may be able to use productively. This type of semaphore is also called a spinlock (because the process spins while waiting for the lock). 22.Write the name of threads where OS is fully aware of its creation and mapping

methods and also give an example of OS that support these threads.02

Answer: Kernel threads are supported directly by the operating system. The kernel performs the scheduling, creation, and management in kernel space; the kernel level threads are hence slower to create and manage, compared to user level threads. However since the kernel is managing threads, if a thread performs a blocking system call, the kernel

Page 14: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

14

can schedule another thread in the application for execution. Windows NT, Windowss 2000, Solaris, BeOS and Tru64 UNIX support kernel threads. 23. Let us consider a situation in which we can perform a same task either by

creating a thread or a child process. Out of thread and a child process, which one you

will choose to perform a task if you don’t have sufficient main memory and you don’t

want context switch to take place? Give reason to support your answer.03 Answer: I will Choose Thread to perform a task. By default, threads share the memory and the resources of the process to which they belong. Code sharing allows an application to have several different threads of activity all within the same address space. 24. Hardware solution to critical section involves use of swap instruction. Write the

code that specifies implementation of mutual exclusion using swap instruction.03

Answer: boolean Swap(boolean &a, boolean &b) { boolean temp=a; a=b; b=temp; } 26. Many solutions to critical section problem are given. One of them is the use of

hardware instructions. Can you specify such type of instructions? Name them and

also tell which of the requirements of critical sections are satisfied by these

instructions and which are not.05

Answer: These instructions are TestAndSet (also known as TestAndSetLock; TSL) and Swap.

• If the machine supports TestAndSet instruction, then we can implement mutual exclusion by declaring a Boolean variable lock, initialized to false.

• TSL-based solution is not good because even though mutual exclusion and progress are satisfied, bounded waiting is not.

• Swap-based solution is not good because even though mutual exclusion and progress are satisfied, bounded waiting is not.

21. There are two assumptions given below: 1) each process executes at a nonzero

speed. 2) No assumption can be made regarding the relative speeds of the N

processes. You have to identify the problem that can be solved by using these

instructions.02

Answer: These Assumption made while formulating a solution to the critical section problem

22. Suppose there is a thread mapping model used to map user-level threads to

kernel-level threads. Here in this model, there exist many kernel-level threads that

support a number of user-level threads and concurrencies in between these threads.

Suggest the name of the model described above. 02

Answer: One-to-One: In this model, there is a kernel thread for every user thread Thus, this model provides true concurrency. This means that a process does not block when a thread makes a system call. The main disadvantage of this model is the overhead of

Page 15: CS604 Operating Systems · [Type the company name] CS604 Operating Systems Midterm 2013 2 jobs kill –l (pg 69) 4. The section of code implementing the request that each process

[Type the company name]

CS604 Operating Systems

Midterm

2013

15

creating a kernel thread per user thread. Examples of these threads are WindowsNT, Windows 2000, and OS/2. 25. Critical section problem have different hardware and software based solution.

There is given below a hardware TestAndSet instruction solution for critical section

problem. You have to identify the shortcoming of this solution?

do

{while (TestAndSet(lock)) ;

Critical section

lock=false;

Remainder section

} while(1);

05

Answer: The above Swap-based solution is not good because even though mutual exclusion and progress are satisfied, bounded waiting is not.