OS Midterm

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

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.

(a) Base & limit addressing.

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. (d) Provide a hierarchy to manage different sections of a program.

(a) Reduce the amount of memory used for storing page tables.

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) Round-robin scheduler.

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) When the outcome of processes is dependent on the exact order of execution among them.

Describe two approaches to avoiding deadlock.

1. detection and recovery 2. dynamic avoidance, banker's algorithm 3. removing any of the 4 conditions (1. mutual exclusion, 2. hold and wait, 3. nonpremption, 4. circular wait)

Name two ways in which the processor can transition from user mode to kernel mode?

1. trap instruction (eg. System call like (open file)) 2. interrupt (eg I/O) 3. Exception (eg divide-by-zero, page fault, segmentation fault)

What is mutex?

A mutex is a lock. It is a program object that allows multiple program threads to share the same resource, such as file access, but not simultaneously. When a program is started, a mutex is created with a unique name. After this stage, any thread that needs the resource must lock the mutex from other threads while it is using the resource. The mutex is set to unlock when the data is no longer needed or the routine is finished.

What is a process?

A process is an instance of a running program. It contains the program code and its current activity, such as registers, variables, program counter, input, output and a state.

What is race condition?

A situation, where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place, is called race condition.

What is a thread?

A thread is the entity within a process that can be scheduled for execution.

What is TLB? What is TLB used for?

A translation look-aside buffer (TLB) is a high speed cache for page table entries (that can either be virtual or part of the physical MMU) containing those that are recently used. It is used to store frequently accessed frames and maps virtual addresses to physical addresses without having to go through the page table.

What are the scheduling algorithm goals for batch, interactive, real-time operating systems?

All systems/Batch Systems/Interactive Systems/Real-time systems

Assume that a main memory access takes 100 ns. If we are using a one-level page table and have a 50% TLB hit ratio, what is the effective memory access time (assume no memory cache and no page faults)?

If TLB HIT: you get the page directly from physical memory and it costs 100ns. If TLB MISS: access page table in memory and it costs 100ns. After that, it takes another 100ns to get the page in the physical memory. So in total it is 200ns. Average access time: 0.5 * 100 + 0.5 * (100 + 100) = 150ns

What is a semaphore?

It is a synchronization tool used to solve complex critical section problems. A semaphore is an integer variable that, apart from initialization, is accessed only through two standard atomic operations: down, and up. Down checks semaphore. If not zero, decrements semaphore. If zero, process goes to sleep Up increments semaphore. If more then one process asleep, one is chosen randomly and enters critical region (first does a down)

What is busy waiting?

The repeated execution of a loop of code while waiting for an event to occur is called busy waiting.

What is the difference between a process and a thread?

Threads are used for `lightweight' tasks, whereas processes are used for more 'heavyweight' tasks. The typical difference is that threads (of the same process) run in a shared memory space, while processes run in separate memory spaces.

What is throughput, turnaround time, waiting time and Response time?

Throughput : number of processes that complete their execution per time unit. Turnaround time : amount of time to execute a particular process. Waiting time: amount of time a process has been waiting in the ready queue. Response time : amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)

What are the disadvantages of context switching?

Time taken for switching from one process to other is pure overhead. The system does no useful work while switching, so one of the solutions is to go for threading when ever possible

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. The technique we use for this is called process synchronization.

What is context switching?

Transferring the control from one process to other process requires saving the state of the old process and loading the saved state for new process. This task is known as context switching.

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

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.

false

Describe how OS deals with a page fault? You should consider using a workflow map in your answer.

refer to sample review guide

FIFO page replacement with 3 physical pages available.

refer to sample review guide

LRU page replacement with 3 physical pages available.

refer to sample review guide

A TLB miss could occur even though the requested page was in memory.

true

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

true

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

true

What is the difference between mutex and semaphore?

Mutex is an object owned by thread, so there is a ownership in mutex. Mutex allow only one thread to access resource. Semaphore is a signaling mechanism. It allows a number of thread to access shared resources.

Name at least four the different job scheduling in operating systems?

Scheduling is the activity of the deciding when process will receive the resources they request. FCFS ---> FCSFS stands for First Come First Served. In FCFS the job that has been waiting the longest is served next. Round Robin Scheduling--->Round Robin scheduling is a scheduling method where each process gets a small quantity of time to run and then it is preempted and the next process gets to run. This is called time-sharing and gives the effect of all the processes running at the same time Shortest Job First ---> The Shortest job First scheduling algorithm is a non-preemptive scheduling algorithm that chooses the job that will execute the shortest amount of time. Priority Scheduling--->Priority scheduling is a scheduling method where at all times the highest priority process is assigned the resource.

What is a context switch? Why is switching threads less costly than switching processes?

a context switch is the process of storing the state of a process or of a thread, so that it can be restored and execution resumed from the same point later. This allows multiple processes to share a single CPU, and is an essential feature of a multitasking operating system. Switching from one process to another requires a certain amount of time for doing all the administration—saving and loading registers and memory maps, updating various tables and lists, flushing and reloading the memory cache, and so on. Thus too much of the CPU time will be thrown away on administrative overhead.

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. get the time of day


Set pelajaran terkait

pro nursing, chp 1 adaptive quiz part 2

View Set

Linux Commands for Testout Security Pro

View Set

Geometry True, Sometimes True, False

View Set

Answer Key to A Winter's Drive and Back Roads Test prep

View Set

Sports and Injuries: Chapter 18,

View Set

Human Needs Neuro and Reproductive

View Set

Ch. 51 Structure and Function Male Reproductive Patho

View Set