CSCI 3000 Quiz 4

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

What is the context switch time, associated with swapping, if a disk drive with a transfer rate of 2 MB/s is used to swap out part of a program that is 200 KB in size? Assume that no seeks are necessary and that the average latency is 15 ms. The time should reflect only the amount of time necessary to swap out the process

200KB / 2048 KB per second + 15 ms = 113 ms

Describe the elements of a hashed page table.

A hashed page table contains hash values which correspond to a virtual page number. Each entry in the hash table contains a linked list of elements that hash to the same location (to handle collisions). Each element consists of three fields: (1) the virtual page number, (2) the value of the mapped page frame, and (3) a pointer to the next element in the linked list.

Using Figure 8.14, describe how a logical address is translated to a physical address

A logical address is generated by the CPU. This logical address consists of a page number and offset. The TLB is first checked to see if the page number is present. If so, a TLB hit, the corresponding page frame is extracted from the TLB, thus producing the physical address. In the case of a TLB miss, the page table must be searched according to page number for the corresponding page frame

Describe a scenario when using a reader-writer lock is more appropriate than another synchronization tool such as a semaphore

A tool such as a semaphore only allows one process to access shared data at a time. Reader-writer locks are useful when it is easy to distinguish if a process is only reading or reading/writing shared data. If a process is only reading shared data, it can access the shared data concurrently with other readers. In the case when there are several readers, a reader-writer lock may be much more efficient.

Given the logical address 0xAEF9 (in hexadecimal) with a page size of 256 bytes, what is the page number? A) 0xAE B) 0xF9 C) 0xA D) 0x00F9

A) 0xAE

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.5 B) 100 C) 22 D) 176.5

A) 108.5

Consider a logical address with 18 bits used to represent an entry in a conventional page table. How many entries are in the conventional page table? A) 262144 B) 1024 C) 1048576 D) 18

A) 262144 (2^18)

Which of the following statements is true? A) Operations on atomic integers do not require locking. B) Operations on atomic integers do require additional locking. C) Linux only provides the atomic_inc() and atomic_sub() operations. D) Operations on atomic integers can be interrupted.

A) Operations on atomic integers do not require locking.

_____ is/are not a technique for managing critical sections in operating systems. A) Peterson's solution B) Preemptive kernel C) Nonpreemptive kernel D) Semaphores

A) Peterson's solution

____________ occurs when a higher-priority process needs to access a data structure that is currently being accessed by a lower-priority process. A) Priority inversion B) Deadlock C) A race condition D) A critical section

A) Priority inversion

A(n) ______ matches the process with each entry in the TLB. A) address-space identifier B) process id C) stack D) page number

A) address-space identifier

The OpenMP #pragma omp critical directive ___________. A) behaves much like a mutex lock B) does not require programmers to identify critical sections C) does not guarantee prevention of race conditions D) is similar to functional languages

A) behaves much like a mutex lock

Absolute code can be generated for ____. A) compile-time binding B) load-time binding C) execution-time binding D) interrupt binding

A) compile-time binding

A(n) _______ refers to where a process is accessing/updating shared data. A) critical section B) entry section C) mutex D) test-and-set

A) critical section

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) inverted

A counting semaphore ____. A) is essentially an integer variable B) is accessed through only one standard operation C) can be modified simultaneously by multiple threads D) cannot be used to control access to a thread's critical sections

A) is essentially an integer variable

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) memory-management-unit (MMU)

With segmentation, a logical address consists of _____. A) segment number and offset B) segment name and offset C) segment number and page number D) segment table and segment number

A) segment number and offset

Using Figure 8.26, describe how address translation is performed on ARM architectures

ARM supports four different page sizes: 4-KB and 16-KB page use two-level paging, the larger 1-MB and 16-MB page sizes use single-level paging. The ARM architecture uses two levels of TLBs - at one level is the micro TLB which is in fact separate TLBs for data and instructions. At the inner level is a single main TLB. Address translation begins wit first searching the micro TLB, and in case of a TLB miss, the main TLB is then checked. If the reference is not in the main TLB, the page table must then be consulted

Describe how an adaptive mutex functions.

An adaptive mutex is used in the Solaris operating system to protect access to shared data. On a multiprocessor system, an adaptive mutex acts as a standard semaphore implemented as a spinlock. If the shared data being accessed is already locked and the thread holding that lock is running on another CPU, the thread spins while waiting for the lock to be released, and the data to become available. If the thread holding the lock is not in the run state, the waiting thread sleeps until the lock becomes available. On a single processor system, spinlocks are not used and the waiting thread always sleeps until the lock becomes available.

When does external fragmentation occur

As processes are loaded and removed from memory, the free memory space is broken into little pieces. External fragmentation exists when there is enough total memory space to satisfy a request, but the available spaces are not contiguous; storage is fragmented into a large number of small holes. Both the first-fit and best-fit strategies for memory allocation suffer from external fragmentation.

Given the logical address 0xAEF9 (in hexadecimal) with a page size of 256 bytes, what is the page offset? A) 0xAE B) 0xF9 C) 0xA D) 0xF900

B) 0xF9

Assume the value of the base and limit registers are 1200 and 350 respectively. Which of the following addresses is legal? A) 355 B) 1200 C) 1551 D) all of the above

B) 1200

How many philosophers may eat simultaneously in the Dining Philosophers problem with 5 philosophers? A) 1 B) 2 C) 3 D) 5

B) 2

_____ 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) Best fit

When using semaphores, a process invokes the wait() operation before accessing its critical section, followed by the signal() operation upon completion of its critical section. Consider reversing the order of these two operations—first calling signal(), then calling wait(). What would be a possible outcome of this? A) Starvation is possible. B) Several processes could be active in their critical sections at the same time. C) Mutual exclusion is still assured. D) Deadlock is possible.

B) Several processes could be active in their critical sections at the same time.

Which of the following is not a reason explaining why mobile devices generally do not support swapping? A) Limited space constraints of flash memory. B) Small size of mobile applications do not require use of swap space. C) Limited number of writes of flash memory. D) Poor throughput between main memory and flash memory.

B) Small size of mobile applications do not require use of swap space.

_____ can be used to prevent busy waiting when implementing a semaphore. A) Spinlocks B) Waiting queues C) Mutex lock D) Allowing the wait() operation to succeed

B) Waiting queues

What is the correct order of operations for protecting a critical section using mutex locks? A) release() followed by acquire() B) acquire() followed by release() C) wait() followed by signal() D) signal() followed by wait()

B) acquire() followed by release()

An instruction that executes atomically ____. A) must consist of only one machine instruction B) executes as a single, uninterruptible unit C) cannot be used to solve the critical section problem D) All of the above

B) executes as a single, uninterruptible unit

A mutex lock ____. A) is exactly like a counting semaphore B) is essentially a boolean variable C) is not guaranteed to be atomic D) can be used to eliminate busy waiting

B) is essentially a boolean variable

An address generated by a CPU is referred to as a ____. A) physical address B) logical address C) post relocation register address D) Memory-Management Unit (MMU) generated address

B) logical address

A race condition ____. A) results when several threads try to access the same data concurrently B) results when several threads try to access and modify the same data concurrently C) will result only if the outcome of execution does not depend on the order in which instructions are executed D) None of the above

B) results when several threads try to access and modify the same data concurrently

Consider a logical address with a page size of 8 KB. How many bits must be used to represent the page offset in the logical address? A) 10 B) 8 C) 13 D) 12

C) 13

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 D) 300

C) 200

Which of the following statements are true with respect to hashed page tables? A) They only work for sparse address spaces. B) The virtual address is used to hash into the hash table. C) A common approach for handling address spaces larger than 32 bits. D) Hash table collisions do not occur because of the importance of paging.

C) A common approach for handling address spaces larger than 32 bits.

_____ is the method of binding instructions and data to memory performed by most generalpurpose operating systems. A) Interrupt binding B) Compile time binding C) Execution time binding D) Load-time binding

C) Execution time binding

Which of the following statements is true? A) A counting semaphore can never be used as a binary semaphore. B) A binary semaphore can never be used as a counting semaphore. C) Spinlocks can be used to prevent busy waiting in the implementation of semaphore. D) Counting semaphores can be used to control access to a resource with a finite number of instances.

C) Spinlocks can be used to prevent busy waiting in the implementation of semaphore.

_____ 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) Worst fit

A solution to the critical section problem does not have to satisfy which of the following requirements? A) mutual exclusion B) progress C) atomicity D) bounded waiting

C) atomicity

In Peterson's solution, the ____ variable indicates if a process is ready to enter its critical section. A) turn B) lock C) flag[i] D) turn[i]

C) flag[i]

The roll out, roll in variant of swapping is used ____. A) when a backing store is not necessary B) for the round-robin scheduling algorithm C) for priority-based scheduling algorithms D) when the load on the system has temporarily been reduced

C) for priority-based scheduling algorithms

A(n) ___________ is a sequence of read-write operations that are atomic. A) atomic integer B) semaphore C) memory transaction D) mutex lock

C) memory transaction

The first readers-writers problem ____. A) requires that, once a writer is ready, that writer performs its write as soon as possible. B) is not used to test synchronization primitives. C) requires that no reader will be kept waiting unless a writer has already obtained permission to use the shared database. D) requires that no reader will be kept waiting unless a reader has already obtained permission to use the shared database.

C) requires that no reader will be kept waiting unless a writer has already obtained permission to use the shared database.

What is the correct order of operations for protecting a critical section using a binary semaphore? A) release() followed by acquire() B) acquire() followed by release() C) wait() followed by signal() D) signal() followed by wait()

C) wait() followed by signal()

Explain two general approaches to handle critical sections in operating systems

Critical sections may use preemptive or nonpreemptive kernels. A preemptive kernel allows a process to be preempted while it is running in kernel mode. A nonpreemptive kernel does not allow a process running in kernel mode to be preempted; a kernel-mode process will run until it exits kernel mode, blocks, or voluntarily yields control of the CPU. A nonpreemptive kernel is essentially free from race conditions on kernel data structures, as the contents of this register will be saved and restored by the interrupt handler.

Consider a 32-bit address for a two-level paging system with an 8 KB page size. The outer page table has 1024 entries. How many bits are used to represent the second-level page table? A) 10 B) 8 C) 12 D) 9

D) 9

Assume an adaptive mutex is used for accessing shared data on a Solaris system with multiprocessing capabilities. Which of the following statements is not true? A) A waiting thread may spin while waiting for the lock to become available. B) A waiting thread may sleep while waiting for the lock to become available. C) The adaptive mutex is only used to protect short segments of code. D) Condition variables and semaphores are never used in place of an adaptive mutex.

D) Condition variables and semaphores are never used in place of an adaptive mutex.

What is the purpose of the mutex semaphore in the implementation of the bounded-buffer problem using semaphores? A) It indicates the number of empty slots in the buffer. B) It indicates the number of occupied slots in the buffer. C) It controls access to the shared buffer. D) It ensures mutual exclusion.

D) It ensures mutual exclusion.

Which of the following is true of compaction? A) It can be done at assembly, load, or execution time. B) It is used to solve the problem of internal fragmentation. C) It cannot shuffle memory contents. D) It is possible only if relocation is dynamic and done at execution time.

D) It is possible only if relocation is dynamic and done at execution time.

_____ is not a technique for handling critical sections in operating systems. A) Nonpreemptive kernels B) Preemptive kernels C) Spinlocks D) Peterson's solution

D) Peterson's solution

Which of the following statements regarding the ARM architecture are false? A) There are essentially four different page ranging from 4-KB to 16-MB in size. B) There are two different levels of TLB. C) One or two level paging may be used. D) The micro TLB must be flushed at each context switch.

D) The micro TLB must be flushed at each context switch.

In a dynamically linked library, ____. A) loading is postponed until execution time B) system language libraries are treated like any other object module C) more disk space is used than in a statically linked library D) a stub is included in the image for each library-routine reference

D) a stub is included in the image for each library-routine reference

Which of the following data structures is appropriate for placing into its own segment? A) heap B) kernel code and data C) user code and data D) all of the above

D) all of the above

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

D) execution time

Another problem related to deadlocks is ____________. A) race conditions B) critical sections C) spinlocks D) indefinite blocking

D) indefinite blocking

A ___ type presents a set of programmer-defined operations that are provided mutual exclusion within it. A) transaction B) signal C) binary D) monitor

D) monitor

Explain the role of the variable preempt_count in the Linux kernel.

Each task maintains a value preempt_count which is the number of locks held by each task. When a lock is acquired, preempt_count is incremented. When a lock is released, preempt_count is decremented. If the task currently running in the kernel has a value of preempt_count > 0, the kernel cannot be preempted as the task currently holds a lock. If the count is zero, the kernel can be preempted.

A 32-bit logical address with 8 KB page size will have 1,000,000 entries in a conventional page table.

False

A deadlock-free solution eliminates the possibility of starvation

False

A relocation register is used to check for invalid memory addresses generated by a CPU

False

Fragmentation does not occur in a paging system

False

Hierarchical page tables are appropriate for 64-bit architectures

False

Inverted page tables require each process to have its own page table

False

Linux mostly uses atomic integers to manage race conditions within the kernel

False

Mobile operating systems typically support swapping

False

Monitors are a theoretical concept and are not practiced in modern programming languages

False

Mutex locks and counting semaphores are essentially the same thing

False

Reentrant code cannot be shared

False

The value of a counting semaphore can range only between 0 and 1.

False

There is a 1:1 correspondence between the number of entries in the TLB and the number of entries in the page table

False

Distinguish between internal and external fragmentation.

Fragmentation occurs when memory is allocated and returned to the system. As this occurs, free memory is broken up into small chunks, often too small to be useful. External fragmentation occurs when there is sufficient total free memory to satisfy a memory request, yet the memory is not contiguous, so it cannot be assigned. Some contiguous allocation schemes may assign a process more memory than it actually requested (i.e. they may assign memory in fixed-block sizes). Internal fragmentation occurs when a process is assigned more memory than it has requested and the wasted memory fragment is internal to a process

How are illegal page addresses recognized and trapped by the operating system

Illegal addresses are trapped by the use of a valid-invalid bit, which is generally attached to each entry in the page table. When this bit is set to "valid," the associated page is in the process's logical address space and is thus a legal (or valid) page. When the bit is set to "invalid," the page is not in the process's logical address space. The operating system sets this bit for each page to allow or disallow access to the page.

What three conditions must be satisfied in order to solve the critical section problem?

In a solution to the critical section problem, no thread may be executing in its critical section if a thread is currently executing in its critical section. Furthermore, only those threads that are not executing in their critical sections can participate in the decision on which process will enter its critical section next. Finally, a bound must exist on the number of times that other threads are allowed to enter their critical state after a thread has made a request to enter its critical state.

Explain why mobile operating systems generally do not support paging

Mobile operating systems typically do not support swapping because file systems are typically employed using flash memory instead of magnetic hard disks. Flash memory is typically limited in size as well as having poor throughput between flash and main memory. Additionally, flash memory can only tolerate a limited number of writes before it becomes less reliable.

Explain how Linux manages race conditions on single-processor systems such as embedded devices.

On multiprocessor machines, Linux uses spin locks to manage race conditions. However, as spin locks are not appropriate on single processor machines, Linux instead disables kernel preemption which acquiring a spin lock, and enables it after releasing the spin lock.

Explain the basic method for implementing paging

Physical memory is broken up into fixed-sized blocks called frames while logical memory is broken up into equal-sized blocks called pages. Whenever the CPU generates a logical address, the page number and offset into that page is used, in conjunction with a page table, to map the request to a location in physical memory

Briefly describe the segmentation memory management scheme. How does it differ from the paging memory management scheme in terms of the user's view of memory

Segmentation views a logical address as a collection of segments. Each segment has a name and length. The addresses specify both the segment name and the offset within the segment. The user therefore specifies each address by two quantities: a segment name and an offset. In contrast, in a paging scheme, the user specifies a single address, which is partitioned by the hardware into a page number and an offset, all invisible to the programmer

What is the difference between software transactional memory and hardware transactional memory?

Software transactional memory (STM) implements transactional memory entirely in software, no special hardware is required. STM works by inserting instrumentation code inside of transaction blocks and typically requires the support of a compiler. Hardware transactional memory (HTM) implements transactional memory entirely in hardware using cache hierarchies and cache coherency protocols to resolve conflicts when shared data resides in separate caches.

Describe the turnstile structure used by Solaris for synchronization

Solaris uses turnstiles to order the list of threads waiting to acquire either an adaptive mutex or a reader-writer lock. The turnstile is a queue structure containing threads blocked on a lock. Each synchronized object with at least one thread blocked on the object's lock requires a separate turnstile. However, rather than associating a turnstile with each synchronized object, Solaris gives each kernel thread its own turnstile.

Explain the difference between the first readers-writers problem and the second readers-writers problem.

The first readers-writers problem requires that no reader will be kept waiting unless a writer has already obtained permission to use the shared database; whereas the second readers- writers problem requires that once a writer is ready, that writer performs its write as soon as possible.

Describe the partitions in a logical-address space of a process in the IA-32 architecture

The logical-address space is divided into two partitions. The first partition consists of up to 8 K segments that are private to that process. The second partition consists of up to 8 K segments that are shared among all the processes. Information about the first partition is kept in the local descriptor table (LDT); information about the second partition is kept in the global descriptor table (GDT).

Describe the dining-philosophers problem and how it relates to operating systems.

The scenario involves five philosophers sitting at a round table with a bowl of food and five chopsticks. Each chopstick sits between two adjacent philosophers. The philosophers are allowed to think and eat. Since two chopsticks are required for each philosopher to eat, and only five chopsticks exist at the table, no two adjacent philosophers may be eating at the same time. A scheduling problem arises as to who gets to eat at what time. This problem is similar to the problem of scheduling processes that require a limited number of resources.

A nonpreemptive kernel is safe from race conditions on kernel data structures

True

A thread will immediately acquire a dispatcher lock that is the signaled state

True

Every object in Java has associated with it a single lock

True

Hashed page tables are commonly used when handling addresses larger than 32 bits

True

Hashed page tables are particularly useful for processes with sparse address spaces

True

Race conditions are prevented by requiring that critical regions be protected by locks

True

The ARM architecture uses both single-level and two-level paging

True

The local variables of a monitor can be accessed by only the local procedures

True

The x86-64 bit architecture only uses 48 of the 64 possible bits for representing virtual address space

True

Without a mechanism such as an address-space identifier, the TLB must be flushed during a context switch.

True

Describe how a transaction look-aside buffer (TLB) assists in the translation of a logical address to a physical address

Typically, large page tables are stored in main memory, and a page-table base register points are saved to the page table. Therefore, two memory accesses are needed to access a byte (one for the page-table entry, one for the byte), causing memory access to be slowed by a factor of 2. The standard solution to this problem is to use a TLB, a special, small fast-lookup hardware cache. The TLB is associative, high speed memory. Each entry consists of a key and value. An item is compared with all keys simultaneously, and if the item is found, the corresponding value is returned.

How is a limit register used for protecting main memory

When the CPU is executing a process, it generates a logical memory address that is added to a relocation register in order to arrive at the physical memory address actually used by main memory. A limit register holds the maximum logical address that the CPU should be able to access. If any logical address is greater than or equal to the value in the limit register, then the logical address is a dangerous address and an error results

What is the advantage of using dynamic loading

With dynamic loading a program does not have to be stored, in its entirety, in main memory. This allows the system to obtain better memory-space utilization. This also allows unused routines to stay out of main memory so that memory can be used more effectively. For example, code used to handle an obscure error would not always use up main memory.

Assume you had a function named update() that updates shared data. Illustrate how a mutex lock named mutex might be used to prevent a race condition in update().

void update() { mutex.acquire(); // update shared data mutex.release(); }

Write two short methods that implement the simple semaphore wait() and signal() operations on global variable S.

wait (S) { while (S <= 0); S--; } signal (S) { S++; }


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

Chapter 14 New Beginnings: Single-Parent Families, Remarriages, and Blended Families

View Set

Economics Final Exam Unit One Review

View Set

CIS 105 Smartphones are really Smart: Sound Byte

View Set

ch. 66: management of patients with neurologic dysfunction

View Set

Exam 2 Chapter 9: Cultural Diversity in Health Care

View Set

All it takes is ten mindful minutes

View Set