CS370 Midterm Study Guide

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Throughput

# of processes that complete their execution per time unit: Maximize

CPU utilization

- keep the CPU as busy as possible: Maximize

Response time

-time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment): Minimize

What three requirements must a solution to the critical-section problem satisfy?

1) Mutual Exclusion 2) Process solution 3)Bound waiting

What will be the value printed at line X? ("PARENT : Value =__") #include <stdio.h>#include <sys/types.h>#include <unistd.h> int value = 15; int main(){pid_t pid; pid = fork();if (pid == 0) { /* child process */value += 15;return 0;}else if (pid > 0) { /* parent process */wait(NULL);printf ("PARENT: value = %d\n",value); /* LINE X */return 0;}}

15

Consider the following processes with the given arrival times and burst times. Obtain a Gantt chart for your own use. Calculate the waiting time for P3, if the scheduling is FCFS.

2

For a process the actual CPU burst durations and guesses are given below. Find the Guess value x. Assume α = 0.5. CPU burst 7 Guess last 3 x

5

We have seen the Dining Philosophers problem with 5 philosophers. How many philosophers can eat at the same time in this case?

5 //because 5/2 = 2.5 which rounds down to 2

We have a large number of images which are each 2 MB. We have a thumb drive with capacity 19 GB. How many images can be stored in the thumb drive?

9,500

What is a command interpreter? How can one be implemented?

A command interpreter allows the user to interact with a program using commands in the form of text lines. It can be implemented by abstracting machine language into human understandable code

What is a context switch? What does the kernel do during a context switch? (What is the difference between this and the previous question?)

A context switch occurs when the kernel transfers control of the CPU from an executing process to another that is ready to run

What is a monitor?

A lock and zero or more condition variables for managing concurrent access to shared data.

What does the long-term scheduler do?

A long-term scheduler is a scheduler that is responsible for bringing processes from the JOB queue (or secondary memory) into the READY queue (or main memory).

How can multilevel queues be scheduled?

A multi-level queue scheduling algorithm partitions the ready queue into several separate queues.

Priority

A priority value (integer) is associated with each process. CPU allocated to process with highest priority.

What happens at process creation and termination?

A process may be terminated after its execution is naturally completed. This process leaves the processor and releases all its resources.

Shortest-remaining-time-first (preemptive SJF)

A process preempted by an arriving process with shorter remaining time

Describe the Dining-Philosophers Problem

A round table of philospohers eat from a shared bowl. A fork is place between each one and you need two forks to eat. Thus, if an adjacent person is eating, you cannot eat until it is finished and you can take their other fork. Eat for a fixed amount of time then stop to allow other processes. illustrates how to avoid deadlock (starvation) of processes where no progress is made.

How should the time quantum be related to the CPU burst times?

A rule of thumb is that 80% of CPU bursts should be smaller than the time quantum.

Define the signal operation: signal(S).

A signal is used to notify a process of an synchronous or asynchronous event.

What is a virtual machine?

A software based emulation of a computer

A system is in a safe state if

A state is safe if the system can allocate resources to each process (up to its maximum) in some order and still avoid a deadlock. More formally, a system is in a safe state only if there exists a safe sequence.

How does a thread differ from a process?

A thread is a lightweight process that can be managed independently by a scheduler.

How is time-sharing usually implemented?

A time shared operating system uses CPU scheduling and multi-programming to provide each user with a small portion of a shared computer at once.

What is time sharing? What kind of scheduling does it involve?

A time shared operating system uses CPU scheduling and multi-programming to provide each user with a small portion of a shared computer at once.

Calculate the Average Waiting Time (AWT) and Average Turnaround time (ATT) for Shortest remaining time first SRTF (Preemptive). Arrival: 0 10 30 50 Burst: 70 50 20 20

AWT: 32.5 ; ATT: 72.5

Consider a these processes. Calculate the Average Waiting Time (AWT) and Average Turnaround time (ATT) for RR scheduling with qunatum=50. For RR assume that the newly arriving process is pushed into the tail before the currently executing process (if they happen at the same time). Arrival: 0 10 30 50 Burst: 70 50 20 20

AWT: 67.5 ; ATT: 107.5

Consider these processes. Calculate the Average Waiting Time (AWT) and Average Turnaround time (ATT) for FCFS and SJF (non-preemptive) scheduling. Arrival: 0 6 18 30 Burst: 42 30 12 12

AWT: FCFS: 36, SJF: 27; ATT:FCFS: 60, SJF:51

For these processes assume that Priority scheduling (non-preemptive) is used. Obtain the Average Waiting Time (AWT) and Average Turnaround time (ATT). 1 indicates highest priority. Arrival: 0 6 18 30 Burst: 42 30 12 12 Priority: 3 2 1 4

AWT:31.44 ATT:55.44

What is the time quantum used for?

Allow a process to run for a limited amount of time before being returned to the queue or finished

How can threads be useful in Java?

Allows a program to operate more efficiently by doing multiple things at the same time.

What is time-sharing? What are the main advantages of time-sharing?

Allows multiple users to share computers simultaneously by switching frequently between terminals

What is throughput?

Amount of a task completed per time unit.

What is an interrupt vector?

An interrupt vector is the memory location of an interrupt handler

SJF (Shortest Job First)

Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time.

Spinlock

Busy waiting lock

What is the difference between I/O-bound jobs and CPU-bound jobs?

CPU bound means the program is bottlenecked by the CPU, or central processing unit, while I/O bound means the program is bottlenecked by I/O, or input/output

What is a CPU burst? What is an I/O burst?

CPU burst is when the process is being executed in the CPU. I/O burst is when the CPU is waiting for I/O for further execution.

Resources required when creating process

CPU time, files, memory, I/O devices etc.

A dual-core system chip has two .. Section 1.3.2

CPUs

Deadlock Characterization

Conditions for deadlock - mutual exclusion, hold and wait, no preemption, circular wait.

Describe the actions taken by a kernel to context switch between kernel-level threads.

Context switching between kernel threads typically requires saving the value of the CPU registers from the thread being switched out and restoring the CPU registers of the new thread being scheduled.

Describe the actions taken by a thread library to context switch between user-level threads

Context switching between user threads involves taking a user thread of its LWP and replacing it with another thread. This act typically involves saving and restoring the state of the registers.

What is meant by starvation in this chapter?

Deadlock

Methods for handling deadlocks

Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock

Round Robin

Each process gets a small unit of CPU time

Describe the layered approach for the structure of operating systems. What are some advantages/disadvantages?

Easier to debug and modify Info is kept only where it is needed Disadvantaged by poorer performance

A Cache memory is faster than magnetic disk but slower than the main memory.

False

A child process always has the same PID as the parent.

False

A routine responding to a system call can be executed in either user mode or kernel mode.

False

A semaphore is the same thing as a mutex lock

False

A system call can only be triggered by hardware. Section 1.5.1

False

A thread has its own thread ID, program counter, register set, and the heap.

False

Monitors represent a theoretical concept that has been proposed which is not encountered in modern programming languages.

False

Registers and cache memories are generally not on the same chip in modern processors.

False

The main difference between a program and a process is that a program is an active entity while a process is a passive entity.

False

The operating system kernel includes all the system programs and as well as the application programs. Section 1.1.3

False

The value of a counting semaphore can only be 0 or 1.

False

You can replace any interrupt by a DMA, that will make things faster.

False

List instructions that might be usable only from supervisor mode in a dual-mode processor.

I/O operations

What resources must be protected by the operating system?

I/O, Memory, and CPU

What are multilevel feedback queues? What are the defining characteristics?

If a process uses too much CPU time, it will be moved to a lower-priority queue. If a process is I/O-bound or an interactive process, it will be moved to a higher-priority queue. If a process is waiting too long in a low-priority queue and starving, it will be aged to a higher-priority queue.

How is a resource allocation graph used to identify a deadlock?

If there is a cycle in the Resource Allocation Graph and each resource in the cycle provides only one instance, then the processes will be in deadlock.

Describe how user threads differ from kernel threads.

In kernel mode, the program has direct and unrestricted access to system resources. In user mode, the application program executes and starts.

What is the difference between asymmetric and symmetric direct communication?

In symmetric multiprocessing, the processors communicate with each other by the shared memory. But, in asymmetric multiprocessing, the processors communicate with the master processor.

Describe the difference between direct and indirect communication.

Indirect: no direct coupling between sender and receiver(s) Direct: explicitly links sender and receiver

What is IPC?

Inter-process communication or inter-process communication (IPC) refers specifically to the mechanisms an operating system provides to allow processes it manages to share data. Typically, applications can use IPC categorized as clients and servers, where the client requests data and the server responds to client requests.

We can say that an operating system is like a government. Why?

It creates an environment within which other programs can do useful work.

Why is the the mutex semaphore used in the implementation of the bounded-buffer problem using semaphores?

It ensures mutual exclusion.

A process can get into the Running state if ..

It is in the Ready state and a scheduler dispatch causes it to run on the CPU

What does the medium-term scheduler do?

It is responsible for swapping of a process from the Main Memory to Secondary Memory and vice-versa.

For the Readers-Writers Problem, we saw the structure of a reader process. Assume that there is curently one reader process that is performing reading, and there are no other processes in the system. What happens if another reader process arrives?

It will enter the section marked as "/* reading is performed */ "

List some of the queues on a typical operating system. Describe the function of each.

Job Queue- Set of all processes in the system Ready Queue- Set of all processes residing in main memory, ready and waiting to execute. Device Queue- Set of processes waiting for an I/O device

How should the time quantum be related to the context switch time?

Most modern systems use time quantum between 10 and 100 milliseconds, and context switch times on the order of 10 microseconds, so the overhead is small relative to the time quantum.

This scheduling approch, by definition, will preempt a process currently running in some circumstances.

NOT priority

A process has multiple threads. Do they all share the same stack.

No, each thread has its own stack.

Describe the 3 multithreading models: many-to-one, one-to-one, many-to-many.

One-to-one: Each user thread is mapped to one kernel thread Many-to-one: Many user threads mapped to one kernel thread Many-to-Many: Many user threads mapped to an equal or lesser number of kernel threads.

Process which creates another process is called a the created process is called a

Parent process Child process

What does preemptive mean? Non-preemptive?

Preemptive scheduling is when a process transitions from a running state to a ready state or from a waiting state to a ready state. Non-preemptive scheduling is employed when a process terminates or transitions from running to waiting state.

Describe one strategy for dealing with deadlocks.

Prevent/Avoid, Detect/Recover, Ignore

What is a PCB?

Printed Circuit Board

FCFS (First Come First Serve)

Process that requests the CPU FIRST is allocated the CPU FIRST

Describe the producer/consumer problem.

Producer and consumer shouldn't access a buffer (critical code) at the same time which is impossible without a solution i.e. semaphores

Identify the true statement.

Reading and writing to ordinary pipes on both UNIX and Windows systems can be performed like ordinary file I/O.

What is multiprogramming?

Running two or more programs simultaneously (or appearing simultaneous)

Describe the Bounded-Buffer Problem

Set number of buffers can only hold one item each

Which of the following statements is true?

Shared memory is generally faster than message passing.

Define operating systems in terms of what they do.

Software that manages a system's hardware

Describe hardware support used to assist the implementation of mutual exclusion?

Supports the idea of locking and provides special atomic instructions

Describe the effect of synchronized in Java

Synchronization in java is the capability to control the access of multiple threads to any shared resource.

We had seen that fork () creates a child process. For the child, which of the following is a possibility?

The child process has a new program loaded into it. The child process runs concurrently with the parent. The child is a duplicate of the parent. ***ALL OF THE ABOVE ***

What is a kernel?

The kernel is a computer program at the core of a computer's operating system and generally has complete control over everything in the system.

Run the code given in Self Exercise 5: Java synchronization several times. Capture the top 5 lines of the output each time. The output looks like this

The output can vary but the format looks like this : T | T | T | T | T | T | T | T | H | T | T | T | T |E| T | T | T | T | T | T | T | H | T | T | T |

In a Unix-like system, the child processes inherit the ordinary pipe from their parent processes because:

The pipe is treated as a file descriptor and child processes inherit open file descriptors from their parents.

Describe the Readers/Writer problem.

The readers-writers problem relates to an object such as a file that is shared between multiple processes.

Define the wait operation: wait(S).

The wait operation decrements the value of its argument S, if it is positive. If S is negative or zero, then no operation is performed.

Examine this code fragment. Select the correct statement. public synchronized void pickup(int i) throws InterruptedException { setState(i, State.HUNGRY); test(i); while (state[i] != State.EATING) { this.wait(); // Recheck condition in loop, // since we might have been notified // when we were still hungry } }

This forms a monitor that provides mutual exclusion and also uses a condition.

___ is defined as the number of processes that finish / time unit is

Throughput

A kernel is a subset of the Operating System.

True

A socket is identified by a string which is an IP address concatenated with a port number.

True

All modern OSs support kernel threads.

True

An operating system decides how to allocate physical memory to various processes.

True

Application programmers using a high level language such as C, use an API rather than directly invoking system calls.

True

Can a system have concurrency without having parallelism?

True

Direct memory access (DMA) is an efficient mechanism for performing I/O when information needs to be transferred in blocks.

True

In Java, calling the start() method will get a Thread object running

True

In Unix, ordinary pipes need a parent-child relationship between the communicating processes.

True

In order to ensure consistancy in a data structure being midified, Deferred cancellation is preferred over asynchronous cancellation.

True

Only the local procedures can access the local variables of a monitor.

True

Round-robin (RR) scheduling becomes first-come-first-served (FCFS) scheduling when the time quantum is very long.

True

The circular-wait condition for a deadlock implies the hold-and-wait condition.

True

True or False? The system model for deadlocks first requires a process request a resource, then use the resource, and finally release the resource.

True

When an interrupt request is accepted by the CPU, there is a transfer of control to the interrupt service routine that handles that specific request .

True

Why have critical sections in programs, as defined by authors of the textbook?

Typically, critical sections prevent thread and process migration between processors and the preemption of processes and threads by interrupts and other processes and threads. Critical sections often allow nesting. Nesting allows multiple critical sections to be entered and exited at little cost.

What is a thread?

Unit of execution of a process

What are the two modes in dual-mode operation

User mode(System mode) and Kernel mode(Supervisor mode)

Completely Fair

Variable time-slice based on number and priority of the tasks in the queue. virtual run time is the weighted run-time

What can be used to prevent busy waiting when a semaphore is implemented?

Waiting queues

What is aging?

When a process has its priority increased over time to make sure it doesn't starve

What is starvation?

When a process never gets run even though it's in the ready queue

What is the dispatcher? What does it do?

When the short term scheduler selects from the ready queue, the Dispatcher performs the task of allocating the selected process to the CPU.

The diagram uses the atomic instruction Swap(&lock, &key) to implement a critical section. The diagram show the value of the shared variable Lock using green or red color. Note that there are three durations during which it is green. Let us assume sometime during the third duration, process 1 executes this code key = TRUE; while (key == TRUE) { Swap(&lock, &key) } Will process 1 enter the critical section (after one or more executions of the while loop)?

Yes, it will enter the critical section.

What variables are used in Peterson's Algorithm? Which are common to both processes?

a bool array flag of size 2 and an int variable turn

What is a critical section?

a group of instructions/statements or region of code that need to be executed atomically

What is a process? What is the difference between a process and a program?

a program is an passive entity while a process is an active entity.

The critical section problem solution:

acquire lock -critical section release lock

When using mutex locks, which is the correct sequence for implementing a critical section?

acquire() followed by release()

Waiting time

amount of time a process has been waiting in the ready queue: Minimize

What is a semaphore?

an integer variable, shared among multiple processes. The main aim of using a semaphore is process synchronization

printf() in C ...

causes a system call

A thread shares the following with peer threads:

code section, data section and OS resources (open files, signals)

This can happen in first-come-first-served scheduling when a process with a long CPU burst is in the CPU.

convoy effect

What is meant by synchronization in this chapter?

coordinating the execution of processes such that no two processes access the same shared resources and data

What does the short-term scheduler do?

decides which of the ready, in-memory processes is to be executed (allocated a CPU) after a clock interrupt, an I/O interrupt, an operating system call or another form of signal.

Symmetric multiprocessing (SMP)

each processor is self-scheduling, all processes in common ready queue, or each has its own private queue of ready processes Currently, most common

An atomic instruction ____.

executes as a single, uninterruptible unit

The exec() system call creates a new process.

false

In Peterson's solution, this variable implies that a process is ready to enter its critical section.

flag[i]

What are the four necessary conditions for characterizing deadlock?

mutual exclusion, hold and wait, no preemption and circular set

What are the Process States

new, running, ready, waiting, terminated

Which multithreading model is common now?

one-to-one

What is mutual exclusion?

only one process at a time can use a resource

Asymmetric multiprocessing

only one processor accesses the system data structures, alleviating the need for data sharing

Modern operating systems most often do this for handling deadlocks.

pretend that deadlocks never occur

Processor affinity

process has affinity for processor on which it is currently running because of info in cache

The shell command ps returns a list of

processes running, including their process IDs (PIDs)

A thread (or lightweight process) basic unit of CPU utilization; it consists of:

program counter, register set and stack space

In a Linux/Unix terminal, you are executing a program program1 using program1 & What happens?

program1 will start executing in the background, and the terminal is available to running other programs or commands.

The two load balancing approaches are these.

push migration, pull migration

MultiLevel Queue

ready queue partitioned into separate queues Variation: Multilevel Feedback queues: priority lower or raised based on history

When send() and receive()are both blocking, the condition is known as a_________________.

rendezvous

A single-core processor can

run multiple threads in parallel, only if there is additional hardware support for multiple thread.

A race condition happens when ____.

several threads try to access and modify the same data concurrently

In RR scheduling, the context-switch time should be __ with respect to the quantum.

small

Which part of a process contains return addresses, parameters, and local variables.

stack

When implicit threading is used, how does the generation of threads happen

the compiler ensures the generation of the threads appropriately

When is the long-term scheduler invoked?

the long-term scheduler may need to be invoked only when a process leaves the system. Because of the longer interval between executions, the long-term scheduler can afford to take more time to decide which process should be selected for execution.

What is the degree of multiprogramming?

the maximum number of processes that a single-processor system can accommodate efficiently

This approach uses an already existing thread, rather than creating a new one, to complete a task.

thread pool

Turnaround time

time to execute a process from submission to completion: Minimize

A multicore system can permit two or more threads to run at the same time.

true

With a buffer of this capacity, the sending process needs to block until the recipient has received the message.

zero capacity


संबंधित स्टडी सेट्स

Health Care Team: Where the LPN Fits

View Set

BUS 207 Exam 2 Practice Problems

View Set

ITN 170 (Linux) Cengage review questions

View Set

Науки, які вивчає біологія

View Set

Pet Practice Test Book 4/Book 5 and PET Trainer WRITING Part 1 MEGA/Uber TEST 2018/19

View Set

Week 3: Check Your Understanding

View Set