CS570 Final

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of the following instructions should be allowed only in kernel mode? A. disable all interrupts B. read the time of day clock C. set the time of day clock D. change the memory map

(O)A. Kernel mode only. Obvious (X)B. Doesn't need to be done only in kernel mode (O)C. Needs to be done only in kernel mode otherwise, a job could set the clock back to increase its processor time slice (among other things) (O)D. Kernel mode only. Obvious

The page number in the 24-bit address 0x123456 with an 256-byte page size is:

0x1234 256 byte page size = 8-bit offset then the first 16 bits will be page number

A logical address of 0x514413ab on a 32-bit page-based virtual memory system with 4 KB pages has the following offset:

0x3ab 4 KB pages → 12-bit offset = bottom three nibbles

Suppose that you have a 32-bit address with a two-level paging hierarchy and a 4 KB page size. The top-level index table has 1024 entries. How many entries does each partial page table have?

1024 (2^10) OFFSET 12 bits: 2nd level page table: 10 bits 1st level page table: 10 bits

With a direct mapping paging system on a 32-bit processor with 32 KB pages, what is the size of each process' page table?

128K entries Page size = 32 KB → 15-bit page offset (2^15 = 32K) If offset = 15 bits then the page # in an address is 32-15 = 17 bits 2^17 = 128K

A system uses 32-bit logical addresses, a 16K byte (2^14) page size, and 36-bit physical addresses (64 GB memory). What is the size of the page table?

2^18 entries Page number = (32 - 14) = 18 bits Page table size = 2^18 page table entries The physical memory address size does not matter.

Which cannot be a valid page size?

3,072 bytes. A page size must be a power of two. 3,072 is not a power of two.

RAID level _____ is also known as block interleaved parity organisation and uses block level striping and keeps a parity block on a separate disk.

4

A system with 32-bit addresses, 1 GB (2^30) main memory, and a 1 megabyte (20-bit) page size will have a page table that contains:

4,096 (4K, 2^12) entries. The amount of main memory does not matter. If the page size takes 20 bits (offset) then the page number takes the first 32-20 = 12 bits 2^12 = 4096 entries

How many times does the following program print hello? #include <stdio.h> #include <unistd.h> main() { if (fork() == 0) printf("hello\n"); else if (fork() == 0) printf("hello\n"); printf("hello\n"); }

5

RAID level ____ spreads parity and data among all N+1 disks rather than storing data in N disks and parity in 1.

5

How many times does the following program print hello? #include <stdio.h> #include <unistd.h> main() { int i; for (i=0; i<3; i++) fork(); printf("hello\n"); }

8 Times fork (); // Line 1 fork (); // Line 2 fork (); // Line 3 L1 // There will be 1 child process / \ // created by line 1. L2 L2 // There will be 2 child processes / \ / \ // created by line 2 L3 L3 L3 L3 // There will be 4 child processes // created by line 3

The wait system call on UNIX systems puts a process to sleep until:

A child process terminates.

What's different between the concepts: process and program?

A process is basically a program in execution.

A process control block is:

A structure that stores information about a single process.

What is a trap instruction? Explain its use in operating systems?

A trap instruction switches the execution mode of a CPU from the user mode to the kernel mode. This instruction allows a user program to invoke functions in the operating system kernel.

What is the difference between an absolute and relative pathname? Give an example of each.

Absolute pathnames start with '/' and specifies a path starting from the root directory (e.g. /bin/csh). Relative pathnames specify a path starting in the current working directory (e.g. ../temp/myStuff.txt)

A Unix inode stores

Access permissions and file allocation information for a file, as well as some other information.

What are the two main functions of an operating system?

An operating system must provide the users with an extended machine, and it must manage the I/O devices and other system resources.

An inode based file system uses 4 Kbyte blocks and 4-byte block numbers. What is the largest file size that the file system can handle if an inode has 12 direct blocks, 1 indirect block, and 1 double indirect block?

Approximately 4 GB. Direct blocks: 12 block pointers × 4K bytes = 48 KB Indirect block: 1 × 1K block pointers × 4K bytes = 4 MB Double indirect block: 1 × 1K block pointers × 1K block pointers × 4K bytes = 4 GB Total size = 4 GB + 4 MB + 48 KB ≈ 4 GB

A USB mouse is a

Character device. Block devices: devices with addressable, persistent block I/O - capable of holding a file system Network devices: packet-based I/O driven by the network subsystem Even a bluetooth mouse is presented as a device, not as a network interface. The bluetooth controller is a network device Character device: accessed as a stream of bytes Bus device: not a device category, although devic drivers usually interact with a bus driver (e.g., USB, PCIx, ...)

The following is not a character device:

DVD

Memory compaction is a technique to

Divides memory into fixed-size chunks.

RAID level 3 supports a lower number of I/Os per second, because _______________

Every disk has to participate in every I/O request

A Page Fault occurs when the desired page table entry is not found in the Translation Lookaside Buffer (TLB)

False

If you have execute-permission for a directory, you can delete a file in that directory

False

It is feasible to have a hard link to a file in a different file system

False

LRU always performs as well or better than FIFO.

False

Programmed I/O (PIO) uses fewer CPU resources than DMA.

False

The Least Recently Used (LRU) replacement policy replaces the page in memory that has been referenced most recently.

False

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

False. Context switches can occur only in kernel mode.

Using mutual exclusion can ensure that a system avoids deadlock.

False. Process P1 holds resource R1 and waits for resource R2 which is held by process P2. Process P2 holds resource R2 and waits for resource R1 which is held by process P1. None of the two processes can complete and release their resource. Thus, both the processes keep waiting infinitely.

In the Dynamic Partitioning technique of memory management, the first-fit placement algorithm scans memory from the location of the last placement and chooses the first available block it finds that satisfies the request

False. Scans the main memory from the beginning and first available block that is large enough

The POSIX execve system call creates a new process.

False. The exec() family of functions replaces the current process image with a new process image. It loads the program into the current process space and runs it from the entry point.

Hardware support for mutual exclusion, such as test-and-set locks has the advantage of avoiding the need for spin locks.

False. The test_and_set sets the contents of a given address to one, and returns the previous value. It can be used to implement a critical section by ensuring that the contents of the address are 1 if and only if a thread is executing within the critical section:

In a memory system employing paging, the chunks of a process (called frames) can be assigned to available chunks of memory (called pages)

False. available chunks of memory -> frames chunks of a process -> pages

When the dirty bit is set in, the contents of the TLB entry do not match the contents in the page table.

False; dirty bit means contents of page in memory do not match contents on disk.

Journaling is preferred for

Faster file system recovery

Briefly (2-3 sentences) state the differences between a hard link and a soft link

Hard links point to the same inode, while soft links simply list a directory entry. Hard links use reference counting. Soft links do not and may have problems withdangling references if the referenced file is moved or deleted. Soft links can span file systems, while hard links are limited to the same file system.

What is multiprogramming? Give 2 reasons for having it.

Having multiple programs resident at once and having them all active at the same time. Only one runs at any instant, but they may each run in turn. This increases CPU utilization, decreases response and turnaround time. While one program is waiting for I/O, another can be using the CPU.

What is the purpose of the cache?

Improving performance by storing frequently-read data in a small portion of memory rather than waiting for the application to access the same data from the main memory.

What is the difference between kernel and user mode?

In Kernel mode, the executing code has complete and unrestricted access to the underlying hardware. In User mode, the executing code has no ability to directly access hardware. Code running in user mode must delegate to system APIs to access hardware.

Page-based virtual memory is subject to

Internal fragmentation

Starvation is the case when a thread:

Is never scheduled to run.

Multiprogramming is:

Keeping several programs in memory at once and switching between them

A superblock holds

Key information about the structure of the file system.

Microsoft's FAT32 file system is an example of:

Linked allocation.

The logs in a log structured file system differ from journaling in that:

Logs are the primary storage structure of the file system. All file system operations are just log writes.

To implement a user-level threads package, it helps if the operating system provides:

Non-blocking system calls.

The real address of a word in memory is translated from the following portions of a virtual address:

Page number and offset

Which state transition is not valid? A. Ready → Blocked B. Running → Ready C. Ready → Running D. Running → Blocked

Ready → Blocked

Contiguous allocation of files has some advantages and some disadvantages. Which of the following is NOT a disadvantage of contiguous allocation?

Slow seek time.

Threads within the same process do not share the same: A. Text segment (instructions). B. Data segment. C. Stack D. Open files.

Stack The primary difference is that threads within the same process run in a shared memory space, while processes run in separate memory spaces.Threads are not independent of one another like processes are, and as a result threads share with other threads their code section, data section, and OS resources (like open files and signals). But, like process, a thread has its own program counter (PC), register set, and stack space.

A File Allocation Table:

Stores a list of blocks used by every single file in the file system. A FAT implements linked allocation. Each FAT entry represents a cluster. The table contains blocks for all files.

The situation that occurs when the desired page table entry is not found in the Translation Lookaside Buffer (TLB) is called a:

TLB miss

Why is a hard link indistinguishable from the original file itself?

The "original file" is really just a hard link itself to the file's inode. If you add a new hard link, it will behave identically.

Disk controllers tend to use Direct Memory Access (DMA) over Programmed I/O (PIO) because:

The CPU does not have to copy the disk data byte by byte.

An advantage of a file allocation table (FAT) file structure over a simple linked file structure is

The file allocation table method allows faster seeks in files.

The page table for each process maintains:

The frame location for each page of the process

A Thread Control Block (PCB) stores:

The machine state (registers, program counter)

A process exists in the zombie (also known as defunct) state because:

The parent may need to read its exit status.

What's the biggest problem with spinlocks?

They waste CPU resources. The problem with spinlocks is if the thread yields while the lock is held, then that can cause any other thread that wants the lock to waste a lot of time spinning.

Please name two advantages to decouple a process address space from the machine's physical memory in modern operating system design.

This allows an executable program to be loaded in different parts of the machine's memory in different runs. Also, it enables program size to exceed the size of the machine's memory.

The situation where the processor spends most of its time swapping process pieces rather than executing instructions is called:

Thrashing

A memory management unit (MMU) is responsible for:

Translating a process' memory addresses to physical addresses The MMU is hardware that is part of the microprocessor. It translates from logical to physical memory locations

A thread that is blocked on a semaphore is awakened when another thread:

Tries to increment the semaphore.

If the hard link is removed, and if the file's (inode's) hard link count goes to 0, the file is also removed

True

The OS can run multiple processes whose total allocated address space exceeds the amount of physical memory available in the system.

True

The modify (M) bit is a control bit in a page table entry that indicates whether the contents of the corresponding page have been altered since the page was last loaded into memory.

True

The problem of internal fragmentation can be lessened in a system employing a fixed-partition memory management scheme by using unequal size partitions.

True

The value of a semaphore can never be negative.

True

Switching among threads in the same process is more efficient than switching among processes.

True. 1. Thread Switching :Thread switching is a type of context switching from one thread to another thread in the same process. Thread switching is very efficient and much cheaper because it involves switching out only identities and resources such as the program counter, registers and stack pointers. The cost of thread-to-thread switching is about the same as the cost of entering and exiting the kernel. 2. Process Switching :Process switching is a type of context switching where we switch one process with another process. It involves switching of all the process resources with those needed by a new process. This means switching the memory address space. This includes memory addresses, page tables, and kernel resources, caches in the processor.

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

True. The biggest advantage is the efficiency. No traps to the kernel are needed to switch threads.

A race condition is

When the outcome of processes is dependent on the exact order of execution among them.

Which memory allocation strategy picks the largest hole?

Worst fit

In UNIX, the return value for the fork system call is _____ for the child process and _____ for the parent process.

Zero, A nonzero integer

Base and limit addressing is most useful in:

a segmentation system.

The memory map of a multithreaded process looks similar to that of a singlethreaded process except that the multithreaded one has:

a stack for each thread Each thread requires a separate stack to be allocated for it (from the memory that is shared among all threads). The heap contains dynamically allocated memory (e.g., via malloc or new) and is shared by all. The data segment contains global variables and is also shared.

Consider a paged virtual memory system. Suppose the page table for the process currently executing on the processor looks like the following. All numbers are decimal, everything is numbered starting from zero, and all addreses are memory byte addresses. The page size is 1024 bytes. Virtual page number Valid bit Reference bit Modify bit Page frame number 0 1 1 0 3 1 0 0 0 - 2 1 0 1 7 3 1 1 1 0 4 1 1 0 2 5 0 0 0 -

a) 1052 = 1024 + 28, so the page number is 1 and the offset is 28. The page table shows that page 1 is not currently resident, so there would be a page fault. b) 2221 = 2 * 1024 + 173 , so the page number is 2 and the offset is 173. The page table shows that page 2 is resident in frame 7, so the physical address would be 7 * 1024 + 173 = 7341.

A process has four page frames allocated to it. (All the following numbers are decimal, and everything is numbered starting from zero). The time of the last loading of a page into each page frame, the time of last access to the page in each page frame, the virtual page number in each page frame, and the referenced (R) and modified (M) bits for each page frame are as shown (the times are in clock ticks from the process start at time zero to the event -- not the number of ticks since the event to the present). Virtual page number Page frame Time loaded Time referenced R bit M bit 2 0 60 164 1 1 1 1 30 166 1 0 0 2 150 162 0 1 3 3 20 163 1 1 A page fault to virtual page 4 has occurred. Which page frame will have its contents replaced for each of the following memory management policies? Explain why in each case. a) FIFO b) LRU

a) 3. The first frame loaded was frame 3, loaded at time 20. b) 2. The least recently referenced frame is frame 0, referenced at time 162. (Note that the question asked for the page frame, not the virtual page number. For part (a), the page frame number and virtual page number happened to be the same, but for this part we have virtual page number 0 in page frame 2.)

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) Yes! b) No. A multi-step lookup is less efficient than a single lookup. c) No. Traversing all page tables across all proceses to look for unused frames is horribly inefficient. d) No. That's segmentation.

A better way of contiguous allocation to extend the file size is :

adding an extent (another chunk of contiguous space)

If a process does not call exec after forking,

all the threads should be duplicated

The NFS servers :

are stateless

A process is moved to wait queue when I/O request is made with

blocking I/O

Mutual exclusion can be provided by the

both mutex locks and binary semaphores

A process can be

both single threaded and multithreaded

If the kernel is single threaded, then any user level thread performing a blocking system call will :

cause the entire process to block even if the other threads are available to run

The VFS (virtual file system) activates file system specific operations to handle local requests according to their ____

file system types

A Translation Lookaside Buffer (TLB) caches:

frequently accessed page table entries.

A binary semaphore puts a thread to sleep:

if it tries to decrement the semaphore's value below 0.

The following page table has the same number of entries as there are page frames:

inverted page table

Which one is not the major methods of allocating disk space mentioned in the textbook?

listed

What is the command to create a soft link "slink" to the file "/u/maclean/junk.txt"?

ln -s /u/maclean/junk.txt slink

The master boot record (MBR)

loads a boot loader from a boot partition.

When hardware is accessed by reading and writing to the specific memory locations, then it is called

memory-mapped I/O

If a process is executing in its critical section, then no other processes can be executing in their critical section. This condition is called

mutual exclusion

A thread shares its resources(like data section, code section, open files, signals) with :

other threads that belong to the same process

If a thread invokes the exec system call,

the program specified in the parameter to exec will replace the entire process

A parent process calling _____ system call will be suspended until children processes terminate.

wait


Conjuntos de estudio relacionados

Finance 342 Chapter 10 Concept Questions

View Set

variable or fixed/ direct or indirect

View Set

C#/Visual Studio/Visual Studio Code -Concepts and Fundamentals

View Set

HESI PN Obstetrics/Maternity Practice Exam

View Set

Artificial Intelligence: A Modern Approach Chapter 3: Solving Problems By Searching

View Set

Ch 27: Nursing Care of the child Born with a Physical or Developmental Challenge

View Set