Midterm Review

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Why is it dangerous to acquire a lock in an interrupt handler?

-lock already held => deadlock / could wait forever or -lock already held, handler sleeps => could get another instance of handler, atomicity lost

What are four strategies to deal with deadlock?

1. Ignore the problem 2. detect and recover 3. dynamic avoidance 4. negate one of the four required conditions

What four conditions must exist in order for deadlock to occur

1. Resource must remain in non-sharable mode (Mutual exclusion) 2. process hold at least one resource and be waiting (Hold and wait) 3. cannot be preempted (No preemption) 4. circular wait exists between processes

A computer system has 6 tape drives, with 'n' processes competing for them. Each process may need 3 tape drives. The maximum value of 'n' for which the system is guaranteed to be deadlock free is : 6 3 2

2

Consider the following two threads, to be run concurrently in a shared memory (all variables are shared between the two threads). Thread A: for i = 1 to 5 do x=x+1 Thread B: for j = 1 to 5 do x=x+1 Assuming a single processor system, that load and store are atomic, that x is initialized to 0, and that x must be loaded into a register before being incremented (and stored back to memory afterwards), what are all the possible values for x after both threads have completed?

2 through 10 inclusive: 2, 3, 4, 5, 6, 7, 8, 9, 10

Consider a local address with 18 bits used to represent an entry in a conventional page table. How many entries are in the conventional page table.

2^18 = 262144

A brand new SGI Altix Intel Itanium system has 64 CPUs running Linux OS. What is the maximum number of processes in RUNNING state at a single time when it executes 200 processes? What is the maximum number of processes in BLOCKED state?

64 processors means 64 max processes running at a single time and the processors can block all 200 processes

Consider a local address with a page size of 8 KB. How many bits must be used to represent the page offset in the local address?

8K page requires 8K 8K = 2^13 since 1K = 2^10 bytes =13 bits

What is the difference between Wait and Signal in a monitor and the general Wait and Signal that correspond to P and V?

A wait statement can block a process's execution, while a signal statement can cause another process to be unblocked.

What is a process?

An instance of a running program. Contains program code and its current activity (register, variables, program counter, input/output)

_____ is the dynamic storage-allocation algorithm which results in the smallest leftover hole in memory. A) First fit B) Best fit C) Worst fit D) None of the above

B

Why is busy waiting a bad idea when running an application with multiple processes on just 1 processor?

Busy waiting wastes CPU cycles that some other process might be able to use productively.

Is context-switching between two threads less expensive than switching between two processes? Why?

Context switching between two threads is less expensive because threads have the same virtual memory maps. When process switching, we are context switching from one process to another which involves switching out all of the process abstractions and resources to the new process. On the other hand, thread switching is context switching from one thread to another in the same process.

What is the difference between deadlock prevention and deadlock avoidance?

Deadlock prevention are methods to ensure that at least one of the necessary conditions for deadlock cannot hold. (makes sure deadlock conditions don't hold) Deadlock avoidance is when the operating system must be given additional information about which resource a process will need, in advance. (OS is given resource process information beforehand)

If the system with paging uses TLB, and has TLB hit rate of 0:9, calculate the effective memory access time for this system. Assume that TLB access requires 10ns and each memory access requires 100ns.

EAT = .9 x (10 + 100) + (1 - .9) x (10 + 100 + 100)

Round Robin Scheduling

Each process gets a small quantity of time to run and then it is preempted, and the next process gets to run. i.e. time sharing

What is a thread?

Entity within a process that can be scheduled

What are the scheduling algorithm goals for all types of systems?

Fairness - giving each process a fair share of the CPU Policy enforcement - seeing that stated policy is carried out Balance - keeping all parts of the system busy

What are the four memory allocation algorithims?

First-fit, next-fit, worst-fit, best-fit

As the amount of addressable physical memory grows, the size of each page-table entry (PTE) must grow as well (true/false)

Generally true, as the PFN must get bigger, and thus the PTE. Could argue that the PTE might be big enough already to accommodate a slightly bigger PFN.

What are interrupts?

Generated by the hardware Asynchronous or "passive" since the interrupt handler has to wait for them to happen eventually.

Worst-Fit:

Gives partitions large spaces as possible. Poor performer because it has to search the complete list.

What is CPU pipeline

Implements a form of parallelism called instruction-level parallelism within a single processor. Allows a faster CPU throughput

Assume that each of the 5 philosophers, , in the dining philosophers problem execute the following segment of code repeatedly: o while( 1 ) { o P( mutex ) o P( fork[i] ) o P( fork[i + 1 modulo 5] ) o V( mutex ) o eat o V( fork[i] ) o V( fork[i + 1 modulo 5] ) o think }

It will create a deadlock and starvation condition when each philosopher will hold one left fork and will wait for another fork.

FSCFS (First Come First Served):

Job that has been waiting the longest is served next.

What is a trap instruction?

Known as an exception or a fault. A trap is a software generated interrupt. A trap results in a switch from user mode to kernel mode.

What are the scheduling algorithm goals for real-time systems?

Meeting deadlines - avoid losing data Predictability - avoid quality degradation in multimedia systems

A computer has 10 tape drives, with n processes competing for them. Each process will need three drives. What is the largest possible value for n, and the system still remain deadlock free? 10 3 4

N = 2 we have two process and each process will use three drives each, this means total we still have 2 drives free hence no deadlock N = 3 we have three process and each process will use three drivers each, this means we have this allocation 3,3,2 where though third process does not have full drives but it will not create deadlock as the any of first process will finish and release a drive. N = 4, we have four process and each process will use three drivers each, this means we need 12 drivers but have only 8 with us, something like 3,3,2,0 here two process will be waiting and could create a deadlock situation as no free drives Hence with N<4 will no deadlock situation.

Acronym for Process State Diagram

NRWRT: Newbies Really Wanna Run This New Ready Waiting Running Terminated

Shortest Job First

Non-preemptive algorithm that chooses the job that will execute the shortest amount of time

What is i-Node? Explain its use in operating systems.

One per file. It is a data structure used to represent a file system object. It tells who owns the file, where its disk blocks are.

Describe page-based virtual memory. You should consider pages, frames, page tables, and Memory Management Units in your answer.

Page based virtual memory ensures ever process has its own address space. Allows programs requiring more RAM to use only what it needs to at any one point. No external fragmentation Allows sharing

What is the basic function of paging?

Permits the physical-address space of a process to be noncontiguous. Avoids fit varied sized memory chunks onto the backing store.

What state information do you need to save/restore about threads when performing a context switch?

Program Counter, Registers, and Stack

First-Fit:

Put data in the first entry that fits the data. Minimizes searching but leads to external fragmentation.

________________ is the amount of time it takes from when a request was submitted until the first response is produced, not output

Response time

What are the scheduling algorithm goals for interactive systems?

Response time - respond to requests quickly Proportionality - meet users' expectations

Next-Fit:

Searches from the last successful allocation. Reduces searching but leaves external fragmentation at the beginning of memory.

Best-Fit:

Searches memory that fits the RAM perfectly; Takes a long time

What is time sharing in OS

Sharing executing power by many users at the same time (CPU).

What is space sharing in OS?

Sharing memory space by many users at the same space (hard disk, RAM)

What are the steps an operating system has to perform during the context switch between two processes (if it uses paging for memory management)?

State save of current process and state restore of different process. Kernel saves context of the old process in its PCB and loads the saved context of the new process scheduled to run.

One of the design decisions in OS memory management is the choice between swapping and paging. Define each of these terms and clarify their respective roles in OS memory management.

Swapping: copies entire process image between memory and disk Paging: Divides logical address space of process into fixed-size pieces

Recall that there are four conditions that must hold in order for a deadlock to be possible. Name one of these conditions that is always present when using synchronization primitives for mutual exclusion and state why the condition must hold?

The limited access (mutual exclusion) condition must hold. This is by definition since limited access must be present for mutual exclusion to be achieved.

What is busy waiting?

The repeated execution of a loop of code while waiting for an event to occur

What is the difference between a process and a thread?

Threads are used for lightweight tasks. Processes are used for heavyweight tasks. Threads run in a shared memory space while processes run in separate memory.

What are the schedule algorithm goals for batch systems?

Throughput - maximize job per hour Turnaround time - minimize time between submission and termination CPU utilization - keep the CPU busy all the time

What is process synchronization?

To guard against the race condition we need to ensure that only one process at a time can be manipulating the same data

What is virtual memory and virtual memory address?

Virtual memory allows a compensate for shortages of physical memory by temporarily transferring pages of program data from main memory to disk storage. Virtual address memory are addresses used by a program

__________ is the amount of time a process has been waiting in the ready queue

Waiting time

A computer has 6 tape drives, with n processes competing for them. Each process will need up to two drives. For which values of n is the system guaranteed to be deadlock free? 6 2 6

With three processes, each one can have two drives. With four processes, the distribution of drives will be (2,2,1,1), allowing the first two processes to finish. With five processes, the distribution of drives will be (2,1,1,1,1). which still allows the first one to finish. With six processes, each holding one tape drive, and wanting another one, we have a deadlock. Thus for n < 6, the system is deadlock free.

A(n) _____ page table has one-page entry for each real page (or frame) of memory. A) inverted B) clustered C) forward-mapped D) virtual

a

Assume a system has a TLB hit ratio of 90%. It requires 15 nanoseconds to access the TLB, and 85 nanoseconds to access main memory. What is the effective memory access time in nanoseconds for this system? A) 108.5B) 100 C) 22 D) 176.5

a

Segmentation is a form of: (a) Base & limit addressing. (b) Direct-mapped paging. (c) Multi-level page tables. (d) Base & limit addressing followed by a page table lookup. (This is segmentation with paging)

a

The mapping of a logical address to a physical address is done in hardware by the ________. A) memory-management-unit (MMU) B) memory address register C) relocation register D) dynamic loading register

a

The reason for using a multilevel page table is to: (a) Reduce the amount of memory used for storing page tables. (b) Make table lookups more efficient than using a single-level table. (c) Make it easier to find unused page frames in the system. (First-fit, best-fit, etc) (d) Provide a hierarchy to manage different sections of a program. (This is segmentation)

a

The two separate modes of operating in a system are: (a) user mode and kernel mode (b) supervisor mode and system mode (c) kernel mode and privileged mode (d) physical mode and logical mode

a

Explain the main purposes of an operating system

abstraction, resource manager

A race condition is: (a) When one process is trying to beat another to execute a region of code. (b) When a process cannot make progress because another one is blocking it. (c) When the outcome of processes is dependent on the exact order of execution among them. (d) A form of locking where processes coordinate for exclusive access to a critical section.

c

Every process gets the same share of the CPU with a: (a) Shortest remaining time first scheduler. (b) Priority scheduler. (c) Round-robin scheduler. (d) Multilevel feedback queues.

c

Suppose a program is operating with execution-time binding and the physical address generated is 300. The relocation register is set to 100. What is the corresponding logical address? A) 199 B) 201 C) 200 Logical addr + relocation = physical addr -> x + 100 = 300 D) 300

c

There four conditions are necessary for a resource deadlock to occur. Which is NOT a condition? (a) Mutual exclusive (b) Hold and wait (c) Preemption (no preemption is the fourth condition) (d) circular wait

c

_____ is the dynamic storage-allocation algorithm which results in the largest leftover hole in memory. A) First fit B) Best fit C) Worst fit D) None of the above

c

The ______ binding scheme facilitates swapping. A) interrupt time B) load time C) assembly time D) execution time

d

Which of the following is most likely to be a system call? (a) The implementation of a while loop in C. (b) Parse a token from a string. (c) Get the cosine of a number. (d) Get the time of day.

d

An interrupt is generated by

external hardware

A context switch from one process to another can be accomplished without executing OS code in kernel mode true/false

false

An advantage of implementing threads in user space is that they don't incure the overhead of having the OS schedule their execution. true/false

false

For machines with 32-bit addresses (i.e. a 4GB address space), since 4GB physical memories are common and cheap, virtual memory is really no longer needed. true/false

false

In round robin scheduling, it is advantageous to give each I/O bound process a longer quantum than each CPU-bound process (since this has the effect of giving the I/O bound process a higher priority). true/false

false

The optimal page replacement algorithm is the best choice in practice true/false

false

Using a multi-level page table increases TLB hit time (true/false)

false (TLB hit time is not affected by page-table structure)

When running on a virtual machine monitor, TLB hits take longer true/false

false (TLB hits, all done in hardware, should take the same time)

The main reason to have a multi-level page table is to speed up address translation. true/false

false (main reason is to save space in memory)

Priority Scheduling

highest priority process is assigned the resource at all times

Effective-Access-Time(EAT) formula:

hit-rate*(E+M) + (1-hit-rate) * (E + 2M) Where E=TLB access time M=Memory access time

Assume that Lock is implemented using a test-and-set instruction and busy (spin) waiting. Also assume that one processor owns the lock and is thus in a critical section and that there are 3 others spinning on the lock. Explain why only one processor will be able to enter the Critical Section after the process currently owning the lock invokes Unlock. As part of your answer, describe a specific worst case scenario.

if one processor is execution the test-and-set then processor can not be pre-empt) that means at single time only one processor will execute Critical Section.

An address generated by a CPU is referred to as a ___.

logical address

For non-shareable resources like a printer, is mutual exclusion necessary?

must exist (printers can't be shared by several processes)

For shareable resources, is mutual exclusion required

no

For mutual exclusion to prevail in the system, at least one resource must be held in a

non-shareable mode

For a hold and wait condition to prevail, a process must be holding at least one resource and waiting to acquire additional resources that are being held by other

processes

An exception is generated by

program error (divide by zero)

Designers decided to use value 1 to represent that a lock is not acquired and value 0 to represent that the lock is acquired by some thread. Implement constructor Lock(), Acquire(), and Release() methods for Lock class using the atomic TEST_AND_SET operation. Write C++-like pseudo code

struct lock { int held = 0; } void acquire (lock) { while (test-and-set(&lock->held)); } void release (lock) { lock->held = 0; }

The request and release of resources are

system calls

________ is the number of processes that complete their execution per time unit

throughput

A TLB miss could occur even though the requested page was in memory true/false

true

A user-level process cannot modify its own page table entries true/false

true

As the size of the virtual address space grows, the amount of space occupied by a linear page table also grows. (true/false)

true

Deadlock can never occur if no process is allowed to hold a resource while requesting another resource. true/false

true

Multithreaded programs are more prone to deadlocks true/false

true

The root directory of a partition in a Unix system is named "/". true/false

true

Threads are cheaper to create than processes true/false

true

The main reason to have a hardware TLB is to speed up address translation. true/false

true (That is the point of the TLB, to cache address translations and hence speed up the entire process)

In a 2-level multi-level page table, each page directory entry should have a valid bit (true/false)

true (This allows us to save space in memory by having large regions of page table left unallocated)

When running on a virtual machine monitor, TLB misses take longer true/false

true (have to bounce into VMM, which may bounce into the OS, and then back to the VMM. However, a software cache of translations in the VMM could help with this)

When running on a virtual machine monitor, the OS still thinks it is in charge of the physical placement of pages. true/false

true (it is an illusion after all)

In a 2-level multi-level page table, the size of the page directory increases as the virtual address space gets larger true/false

true (you need more page-directory entries to point to all those parts of the page table)

____________________ is the amount of time to execute a particular process

turnaround time

A trap is generated by:

user process


Ensembles d'études connexes

Chapter 9 Muscular System Part 2

View Set

Lesson 4: Comparing Local Networking Hardware

View Set

MARK3336 Ch. 5 Video: IMG World: Creating the College Experience

View Set

Med/Surg 3 Chapter 11 NCLEX Style Questions

View Set

Ch 05 - Infertility, Contraception, & Abortion

View Set