OS Midterm

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Starvation occurs when

Resources are never available

What is a device Minor number?

A number to differentiate all the devices belonging to a specific device driver. Non of the

In interrupt-driven I\O, _______ raises an interrupt by asserting a signal on the interrupt request line.

Device Controller

To start an I/O operation, device driver loads the appropriate registers within the _________.

Device Controller

The process of indexing into the trap table to jump to the trap handler routine is called ______

Dispatching

Process Management

Responsible for process creation, deletion, scheduling, synchronization and inter-process communication

Answer the questions below based on the following code: int main(){ int pid1=fork(); int pid2=fork(); printf("Hello\n"); if(!pid1 && !pid2) printf("World\n"); return 0; } How many times does the following word get printed out: Hello:________(1) World:________(2)

1) 4 2) 1

A keyboard is a __(1)__ while a printer is a __(2)__.

1) character device 2) block device

A process's ___(1)____ stores dynamically allocated variables, while the ____(2)___ is used to store local variables. For example, allocating memory with the malloc() function will place the data on the ___(3)____

1) heap 2) stack 3) heap

When the user calls the kernel to send RPC message to a procedure, the kernel then sends a message to ______(1)_______ to find _____(2)______ . An answer is now received by the kernel (client), which then places the answer in _____(3)_____ and the kernel actually sends a _____(4)_____ . This is then received by a ____(5)_____ that is listening and it processes the request and sends the output back to the kernel, which then passes the reply to the user.

1) matchmaker 2) port number 3) user RPC message 4) Remote procedure call 5) Daemon

The ___(1)___ instruction interrupts the OS to signal to switch into __(2)__ mode, which is needed for a system call

1) trap 2) kernel

Given the following scenarios 1. Multitasking 2. Interrupt handling 3. User and kernel mode switching What are the potential triggers for a context switch?

1, 2, and 3

Choose the correct answer 1. A virtual machine executes on a host operating system and a hypervisor provides an API to the actual hardware 2. The guest OS knows that it is not accessing the actual hardware so that it can perform better 3. The VM may supply an environment that is different than the actual host hardware 4. Applications running within the VM have an illusion that they are executing on a real machine

1, 3, 4

A counting semaphore is initialized to 15. 8 wait operations and 7 signal operations were completed on this semaphore. What is the resulting value of semaphore?

14

Choose the correct answer 1. In multitasking, one or more processes are loaded in main memory to execute and only one process at a time is able to get the CPU while all the others are waiting in the ready queue 2. In multiprogramming, one or more processes are loaded in main memory to execute and only one process at a time is able to get the CPU while all the others are waiting in the ready queue 3. In multitasking, multiple processes are running concurrently and each process will share the CPU 4. In multiprogramming, multiple processes are running concurrently and each process will share the CPU 5. In batch scheduling of multiprogramming, once a process is started, it will control the CPU until its completion regardless of any idle CPU time 6. In co-operative scheduling, when a process needs to wait for resources, it will give up the CPU and be removed from the ready state

2, 3, 5 and 6

How does a user application access system code within the OS? The list of steps are given below, but the order is not correct. Choose the correct order which describes the way in which the CPU gets to know what code is running 1. Kernel process a trap. The trap handler will index into jump table to find the handler for a specific system call and jump into the code 2. Control is returned to the user space code following the trap invocation 3. Mode bit is switched into kernel mode from user mode 4. Mode bit is switched from kernel mode into user mode 5. System call is made which places the system call id into a register and the trap instruction is thrown

5, 3, 1, 4, 2

Which of the following is TRUE regarding the relationship between processes and threads a. It takes far less time to create a new thread in an existing process than to create a new process b. It takes less time to terminate a process than a thread c. It takes less time to switch between two different processes than tp switch between two threads within the same process d. All of the above

A

How are the Parameters passed to and results are returned from a system call a. Parameters can be passed in registers b. When there are more parameters than registers, the OS cannot pass them onto the registers without clearing up all the registers c. When there are more parameters than the registers, store the parameters in a block and pass the block address as a parameter to a register d. Parameters can be pushed on and popped off the stack by the OS e. Parameters are copied to a special register, parameter register, and they are always stored in that register f. All the options are correct

A, C, and D

Mark all valid deadlock prevention schemes: a. Request and allocate all the resources required to a process before the process execution b. Number the resources and never request a lower number resource than the allocated ones c. Release all resources before requesting a new resource d. Never request a resource after releasing any resource

A,B, and C

Select the best answer with respect to deadlock elimination. A) We can eliminate deadlock by terminating all the processes that are deadlocked. B) We can eliminate deadlock by terminating one process at a time until a deadlock cycle is eliminated. C) We can eliminate deadlock by informing the operator that a deadlock has occurred and lets the operator deal with the deadlock manually. D) We can eliminate deadlock by successively pre-empting some resources from processes and giving these resources to other processes until the deadlock cycle is broken.

All of them are true

Memory Management

Allocating and deallocating free space for processes and keeping track of what space is being used by every process

Which of the following must hold for a deadlock to occur a. Mutual Exclusion b. Hold and wait c. No preemption d. Circular wait e. All of the above

E

Critical Section

Area in code where processes access shared resources.

Select all the options that are true regarding the code that runs in user space and kernel space A. The user code shall allocate or deallocate memory without making a request to the kernel B. The kernel ensures that the user code cannot modify the underlying OS data and data structures C. In order to limit what user software actions may do on a system, the kernel operates in a separate kernel space and the user code operates in user space D. Code running in user space cannot be accessed by the kernel without a system call, in the same way like user space code cannot access the code kernel space without issuing a system call

B and C

Which of the following are shared across threads in a multithreaded process? a. Register values b. Global variables c. Heap memory d. Stack memory

B and C

Which of the following statements are TRUE about user-level threads and kernel level threads? a. Blocking one kernel level thread blocks all related threads b. Blocking one user level thread blocks the entire process c. Operating system doesn't recognize user level threads d. Context switch time for kernel threads > user level threads

B, C and D

What is the difference between Blocking vs non-blocking I/O system calls?

Blocking I/O system calls put processes on a wait queue until I/O completes, while non-blocking I/O system calls return immediately and Blocking I/O system calls are synchronous, while non-blocking I/O system calls are asynchronous

In RPC, communicating processes can be ______ a. On the same host b. On different remote hosts c. Both A and B d. None of the above

C

Which of the following is False? a. The purpose of DMA is to free up the CPU during expensive I/O transfers b. DMA sends an interrupt to the CPU when it is finished c. If DMA hardware is present for I/O transfers, it will always invoke itself to do any I/O transfer d. DMA is made possible through specialized hardware

C

Which of the following is an advantage of LKMs. a. Unused LKMs are a waste of memory since they are loaded at launch. b. LKMs do not require kernel mode access. c. Functionality may be added or removed from the kernel without a reboot. d. If the LKM has an error, it requires a total recompile of the kernel.

C

Requiring that there be a total ordering among the resources that each process will request prevents which necessary condition for deadlock.

Circular Wait

Dining philosophers problem is a classic synchronization problem. What problem are we specifically concerned about?

Deadlock

What problem can arise when implementing synchronization with Semaphores?

Deadlock

One algorithm simulates the possible future execution of the system, based on the assumption that every process will only complete after its declared maximum total resource allocations have all been satisfied, to see if the maximum future requests of all processes can be satisfied and so they will all be able to complete. This algorithm is used for

Deadlock avoidance/Deadlock detection

A process manager provides for: a. creation\deletion of processes b. synchronization of processes c. monitoring and scheduling of processes d. All of the above

D

In Reader/Writer problem our goals for a solution must resolve which of the following problems: a. Race Condition b. Starvation c. Deadlocks d. All of the above

D

Which one of the following is a "Hold and Wait" deadlock prevention solution: a. Release all held resources before requesting a set of new ones simultaneously b. Only allow a process to hold one resource at a time c. Request all resources at process creation d. All of the above

D

A binary semaphore provides the same functionality as a mutex. (T/F)

False

A mutex would be preferred over a semaphore if the order of execution of critical sections for different processes was desired. (T/F)

False

A system in an unsafe state is one in deadlock.(T/F)

False

As more deadlocks occur, you should run deadlock prevention algorithms less frequently because those algorithms can potentially lead to deadlocks. (T/F)

False

Compared to processes, threads have less memory consumption, have faster context switches, are more reliable/safe, faster to create and delete, and have faster communication (T/F)

False

In general, with N processes sharing N semaphores, the potential for deadlock decreases as N grows larger. (T/F)

False

Signaling with a condition variable is the same as signaling with a semaphore (T/F)

False

The Java Virtual Machine is able to interpret Java application code directly (T/F)

False

The exec() command will return the Process ID (PID) of the most recently executed program.(T/F)

False

The exec() command will spawn a new process and begin executing at the same point as the parent (T/F)

False

The exec() command will spawn a new process and begin executing at the same point as the parent. (T/F)

False

The key difference between a binary semaphore and a mutex is that mutex can be owned by two tasks, whereas a binary semaphore can be owned only by one task (T/F)

False

What is the interface between the virtual machine and the host machine is called?

Hypervisor

Who initiates a DMA transfer?

I/O devices

Protection

In a multiprogramming environment, each process that runs on the OS has its own set of resources and other processes cannot access those resources. The OS controls the access to all resources from internal and external access.

Resource Management

In a multiprogramming environment, the OS allows multiple applications to share resources, protects apps from each other, and improves performance by efficient utilization of resources

_____ I/O is efficient when the device is rarely available to be serviced.

Interrupt driven

Hardware Abstraction

It provides a high level view of the system so that programs can be written easily without the programmer having to worry about the nitty-gritty details of the hardware.

Which one of the following is NOT a method to pass parameters to the OS using system calls? a. Pointers b. Registers c. Lists d. Stack e. None of the above

Lists

The Kernel identifies a driver with a _________.

Major number

File and Storage Management

Mapping files onto secondary storage and manages free space

In the parent process, the fork() command should return

PID of child

_________________ is a scenario in which a high priority task is indirectly preempted by a lower priority task forcing the higher-priority task to wait for lower priority task.

Priority Inversion

In a process control block which of the following is used to retrieve the information on the next instruction to be executed? a. CPU registers b. Process state c. Program counter d. Process number

Program Counter

I/O Management

Provides a device driver interface for applications for easy access to any external device without knowing the internal details of the hardware

A ______ occurs when two or more threads try to access the same share data and try to change them at the same time

Race Condition

In interprocess communication, a pipe may be used to _______

Send data unidirectionally

int temp; void swap(int *y, int *z) { int local; local = temp; temp = *y; *y = *z; *z = temp; temp = local; } Select the best answer regarding the given code snippet a. The code is neither thread safe nor re-entrant b. The code is re-entrant but not thread safe c. The code is re-entrant and thread safe d. The code is thread safe but not re-entrant

The code is re-entrant but not thread safe

Mutual Exclusion

The idea of which we want to prevent one process from accessing a resource while the current process is modifying said shared resource.

A Monitor is an object designed to be accessed from multiple threads. The member functions or methods of a monitor object are mutually exclusive. (T/F)

True

Message Passing IPC is generally slower than Shared Memory IPC (T/F)

True

Shared Memory IPC can lead to synchronization errors (T/F)

True

The test and set instruction provides atomicity, takes advantage of special hardware, and cannot be interrupted. (T/F)

True

Race condition

When two or more threads try to change the shared data at the same time.

Where can the initial boot loader be? a. EPROM b. ROM c. RAM d. External hard drive

a and b

Every process state in an OS is represented by:

a process control block

What are the benefit of virtual machines? a. Run multiple OS's simultaneously b. Provide fault isolation if an OS fails c. Deploy applications to more users d. Emulate the same hardware platform in the host machine only

a, b, and c

Select all the options that are true about pipes and sockets. a. Sockets in general use a client-server architecture. b. Named pipes in the Windows OS can be used over a network, while ordinary pipes cannot. c. Pipes communicate by means of producer-consumer fashion. d. Ordinary pipes are bi-directional, which allow two-way communication. e. Sockets can allow structured stream of bytes to be exchanged between the communicating threads. f. Named pipes require no parent-child relationship.

a, b, c and f

What are the conditions that must be met for a deadlock to occur? Select all the options that are true. Select one or more: a. Mutual Exclusion b. Hold and wait c. No preemption d. Circular wait e. Starvation f. Intermittent I/O g. Buffer overflow h. Bounded buffer

a, b, c, and d

What are the different ways of doing IPC? Select all options that are true. a. Remote procedure calls b. Interrupts c. Shared memory d. Signals e. Parameter passing f. Kernel I/O g. Message passing h. loadable kernel modules

a, c ,d, and g

Choose all the options that are true about semaphores Select one or more: a. A basic semaphore can be implemented using an integer variable. b. The value of a binary semaphore can take any real value between 0 and 1. c. Counting semaphores can range over an unrestricted domain. d. Two processes cannot execute wait() and signal() operations on the same semaphore at the same time. e. SInce semaphores are managed by the OS, two processes can issue wait() or signal() operations on the same semaphore at the same time. f. If a semaphore is implemented using a waiting queue, deadlocks can occur between processes because of the signal() event.

a, c, d and f

A solution to race condition should have which of the following properties? a. are Mutually Exclusive b. is only protected by mutexes c. prevents Deadlock d. is only protected by semaphores e. can only be scheduled if it has the resource f. provide Progress - a process who has access to the resource must be actively making progress in its critical section g. have Bounded Waiting (starvation free) - no process can wait forever to access its critical section

a, f and g

Which of the following is true: A) A function defined within the monitor can access only those variables which are declared locally within the monitor. B) Local variables of a monitor can be accessed only by its local functions.

both

Which of the following statements is correct. a. A mouse is more likely to be a polling I/O device while a hard drive is more likely to be an interrupt-driven I/O device. b. Both devices are more suited to be polling I/O devices. c. Both devices are more suited to be interrupt-driven I/O devices. d. A hard drive is more likely to be a polling I/O device while a mouse is more likely to be an interrupt-driven I/O device.

both a and c are correct options

During a ________, the state of the process is saved and written to RAM and the process state for the new process which gets to run is loaded from RAM and the new process starts running

context switch

Concurrency is:

interleaving of processes to stimulate parallelism

Mode bit = 0 indicates

kernel mode

In a micro-kernel how do we communicate to services that are not monolithically in the OS?

message passing

Choose the correct answer based on the following statements regarding shared memory that is accessed by multiple threads 1) Shared memory can run into race conditions if it is not accessed in the correct order by the threads. 2) Since the shared memory is isolated between the threads, the main advantage of using shared memory is that it can never run into race conditions. 3) Shared memory has a serious disadvantage of leaving processes to starve since a single thread can hog the resource by never letting the other threads to access it. 4) Even though the memory is shared, there need not be any synchronization mechanisms for shared memory because the OS will take care of the thread management on its own. 5) Shared memory provides an extremely fast way to communicate large or small amounts of data because any data, that is written by one thread to a shared memory region, can be read immediately by any other thread that has the privilege to read from that memory location.

only 1, 3 and 5 are true

Which function is used to attach shared memory to a process

shmat()

s the function f() thread-safe? Is f() reentrant()? int g= 0; int f(int i){ int x = g; x = x - 2; x = i; x = x*x; return x; }

thread-safe, thread-reentrant

In the child process, the fork() command should return

value of 0

Which of the following conditions can you guarantee from the three processes below? (Assume s1 and s2 are semaphores initialized to 0) P0: wait(&s1); x1; x2; wait(&s2); x3; P1: wait(&s1); y1; signal(&s2); y2; P2: z0; signal(&s1); z1; signal(&s1);

y1 executes before x3


Set pelajaran terkait

CIS Exam, Questions from quizzes

View Set

Accounting Exam 3 Multiple Choice

View Set

PDBIO 210 --Lesson 6 -- Appendicular Skeleton--Pelvic girdle, os coxae

View Set

Ch. 56 Acute Intracranial Problems

View Set

MS PL-100 Individual Question Sets

View Set