480 OS Midterm

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

Given the following concurrent code and share the variable y: thread 1 thread 2 x = 0 y = 10 y = x + 7 y = y + 2 How many different values can y possibly have at the end of all the statements due to race condition?

3

The difference between program and process includes:

A process has address space but a program does not.

The readers-writers problem (assuming the first readers-writers problem where the reader has priority over writer)

A writer may starve if a continuous series of readers arrive before the earlier readers exit their critical section.

Consider a situation in which 3 processes are accessing a shared queue. The operation Enq(x) adds the data x to the tail of the queue. Assume that Enq() is written with mutual exclusion guaranteed, thus the queue data structure cannot be corrupted by concurrent Enq() operations. The relevant code segment for the processes is given below: Process A: Enq(X); Signal(s); Process B: Wait(s); Enq(Y); Process C: Enq(Z); Signal(s); Assume that the initial value of the semaphore S is 0. List all possible final states of the queue.

A,B,C = XYZ A,C,B = XZY B,A,C = XYZ REPEAT FINAL STATE B,C,A = ZYX C,A,B = ZXY C,B,A = ZYX REPEAT FINAL STATE XYZ, XZY, ZYX, ZXY

Consider the following set of processes on a single CPU machine, under an FCFS scheduling policy. Note that in the beginning only A exists; B is forked by A. Assume that the semaphores S1 and S2 have an initial value of 0. Trace the execution of this set of processes. You need to clearly indicate when a process blocks and wakes up. In FCFS, a process will always keep execution until it is blocked. Process A: A1; fork(B); wait(S1); A2; signal(S2); Process B: B1; signal(S1); wait(S2); B2; Note that A1, A2, B1, B2 are code segments in the process A or B. The trace can be in the form of "Process:Segment; Process:Segment.... ". Example of trace format: A: A1; B: B1; B:signal(S1). (This is not the answer of course.)

A: A1; A: fork(B); A: wait(S1); B: B1; B: signal(S1); B: wait(S2); A: A2; A: signal(S2); B: B2;

Which of the following can be a solution to the problem of indefinite blockage of low-priority processes?

Aging

Which are included in the context of a thread? register set stacks private storage area all of the above

All of the rest

Which of the following statements is true about kernel synchronization in Linux? The Linux kernel is designed so that the spinlock is held only for only short durations When a lock must be held for a longer period, semaphores or mutex locks are appropriate for use. Spinlocks cannot be used on single processor machines. On multiple process machines, Linux uses spinlock as the fundamental locking mechanism. All of the rest

All of the rest

Which of the following are correct about threads, processes and programs?

All of the rest.

Which of the following statements is NOT correct about today's operating systems?

Any operating system must provide three types of user interfaces namely command line, graphical user interfaces and touch-screen interface.

If the time quantum gets too large, RR scheduling degenerates to __________?

FCFS

Which of the following scheduling algorithm may suffer from convoy effect?

FCFS

Which of the following scheduling algorithms must be nonpreemptive?

FCFS

A deadlock-free solution is guaranteed to be starvation-free

False

A preemptive kernel means that a process running in kernel mode could not be preempted but a process running in user mode could be preempted.

False

Although some CPU scheduling criteria are not compatible, minimizing turnaround time guarantees minimizing response time.

False

POSIX semaphore API such as sem_wait() returns a positive integer if the function is executed successfully.

False

Parallelism can be achieved on single-processor systems.

False

The bootstrap program resides entirely in main memory (RAM).

False

Thread pool has overhead and thus is usually slower to service requests compared with creating a new thread each time.

False

True/False: in the solution for bounded buffer problem written using three semaphores (full, empty and mutex), It does not work correctly if there are more than one producer or consumer because the mutex semaphore must be initialized to 1. The wait operation on mutex semaphore can be switched with the wait operation of the full or empty semaphore in the code without causing any potential issue. The full operation was initialized to 0 because it provides mutual exclusion.

False

CPU schedule criteria:

If the number of processes that complete their execution per time unit increases, the system throughput increases.

The queue associated with a semaphore implementation is for processes/threads waiting for the CPU None of the rest processes/threads that are doing busy waiting the dispatcher to decide when an I/O burst is done

None of the rest

If process P0 is switched to process P1, state for P0 will be saved into ____, and state from ___ will be reloaded?

PCB0, PCB1

For each case, list the waiting time of each process in the ready queue, then calculate the total waiting time of all processes: Preemptive SJF: Three processes P1 - P3 arrive at time 0, 1, and 6 (ms), with the lengths of the CPU bursts being 3ms, 6ms and 1ms respectively. Round-Robin: Five processes P1 - P5 arrive at time 0, 0, 2, 2, 2, with the lengths of the CPU bursts being 2, 5, 6, 5, 4 ms respectively. The quantum is 2ms. (Assume that when a process's quantum expires, it will be moved to the tail of the ready queue.)

Preemptive SJF: P1: 0 P2: 3 P3: 0 Total: 3 Round-Robin: Waiting Time P1: 0 P2: 14 P3: 13 P4: 15 P5: 12 Total: 54

____________ occurs when a higher-priority process needs to access a data structure that is currently being accessed by a lower-priority process.

Priority inversion

Which of the following criteria is more important for an interactive system?

Response Time

Scheduling algorithm that gives the minimum average waiting time for a given set of processes?

SJF

Shortest-remaining-time-first scheduling is the preemptive version of __________?

SJF

System calls and general C library functions have the following differences:

System calls are entry points into the kernel, but general functions are not.

Which of the following is incorrect?

The quantum of the round robin algorithm is the smaller the better.

Storage hierarchy:

The upper level storage devices such as registers are usually more expensive than the lower level storage such as main memory. The upper level storage devices such as registers are usually faster than the lower level storage such as main memory. The upper level storage devices such as registers are usually smaller than the lower level storage such as main memory.

threads, processes and programs:

Threads are more vulnerable to problems caused by other threads in the same process A process can contain one or more threads. A program can become one or more processes.

A deferred thread cancellation means that the target thread has an opportunity to decide when is a good time to exit.

True

Allowing at most four philosophers to sit simultaneously can limit the use of the resources

True

Allowing at most four philosophers to sit simultaneously prevents deadlock.

True

At any given time, at most one writer can do writing.

True

Command interpreter is a system program (T/F):

True

Dining philosophers problem is important because it represents a class of problems where multiple processes need to share multiple resources.

True

If a web server runs as a single-threaded process, only one client can be serviced at a time. This could result in potentially enormous wait times for a busy server. True or False?

True

If a web server runs as a single-threaded process, which means that only one client can be serviced at a time. This could result in potentially enormous wait times for a busy server.

True

Source code management. is NOT a function of the operating system?

True

The Completely Fair Scheduler (CFS) is the default scheduler for Linux systems.

True

The system() library function creates a child process that executes the shell command specified in the argument.

True

True/False: fork() return 0 in the child process.

True

Turnaround time measures the amount of time it takes to execute a process. Response time is a measure of the time that elapses between a request and the first response produced. Turnaround time is the sum of the periods that a process is spent waiting to get into memory, waiting in the ready queue, executing on the CPU, and doing I/O.

True

Virtual machine allows us to abstract the hardware of a single computer (the CPU, memory, disk drives, network interface cards, and so forth) into several different execution environments.

True

Calculate the waiting time of each process in the ready queue, then calculate the total waiting time of all processes: The CPU scheduling algorithm is FCFS: Three processes P1 - P3 arrive at time 0, 1, and 6 (ms), with the lengths of the CPU bursts being 3ms, 6ms and 1ms respectively.

Your Answer Waiting = completion - arrival - burst P1: 3 - 0 - 3 = 0 ms P2: 9 - 1 - 6 = 2 ms P3: 10 - 6 - 1 = 3 ms Total = 5 ms

a) List all different states for a process, and the events that would trigger the transitions among them. You do not need to draw the transition diagram. Just list in text. b) Then list at least two cases where transitions are NOT allowed.

a) New, Running, Waiting, Ready, Terminated b) 1) Ready->New, once it is ready it cannot be returned to new 2) Waiting->Running, it must transition to ready first

In the monitor solution for dining-philosophers problem, a philosopher may start eating

after exiting the pickup( ) function and before entering the putdown( ) function.

Which of the following is NOT one of the major category of system calls?

cyber security

In the solution provided for first readers-writers problem, if a writer is in the critical section, and multiple readers and writers are waiting,

either all waiting readers or exactly one writer will be allowed to enter the critical section.

A context switch

has overhead that wastes system resource.

Which of these is NOT included in the PCB? a copy of the registers. local variable. accounting information. a copy of the program counter.

local variable.

Which of the following is a good criterion for CPU scheduling?

minimize process turnaround

The _____ model maps each user-level thread to one kernel thread.

one-to-one

inter-process communication:

ordinary pipe is uni-directional. socket, a communication mechanism in a client-server system, is a concatenation of an IP address and a port. ordinary pipe is often used for communication between a process and its child.

An operating system

provides services such as user-OS interface

The list of processes waiting to execute on a CPU is called a(n) ____.

ready queue

Assume process P0 and P1 are the process before and after a context switch, and PCB0 and PCB1 are respectively their process control block. Which of the following time units are included inside the dispatch latency?

save state into PCB0, and restore state from PCB1

A process's stack section

stores function parameters

Moore's Law predicts that

the number of transistors on a chip increases exponentially.

A reader-writer lock developed based on the reader-writer problem is useful when

there are a significantly large number of reader processes attempting to read.

Linux Kernel

was modified in Android to provide power management

Convoy effect happens

when short processes are behind long processes


Set pelajaran terkait

Chapter 25: Growth and Development of the Newborn and Infant

View Set

chapter 19-3 life, health, and social insurance

View Set

Chapter: Chapter 36: Nursing Assessment: Immune Function

View Set

History of Rock and Roll Exam #1 Terms

View Set

Spanish 101 ch.2 PRESENT TENSE -ar VERBS, ser and estar

View Set

CH 3 State Courts, CH 2 Federal Courts, CH 1 Courts

View Set

HRM 6605 Chapter 3 Title VII of the Civil Rights Act of 1964

View Set

Chapter 22 Benefits of Using Assessment Data to Drive Instruction

View Set