qa7-9

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

Compare the circular-wait scheme with the deadlock-avoidance schemes(like the banker's algorithm) with respect to the following issues: a. Runtime overheads b. System throughput

A deadlock-avoidance scheme tends to increase the runtime overheads due to the cost of keeping track of the current resource allocation. However, a deadlock-avoidance scheme allows for more concurrent use of resources than schemes that statically prevent the formation of dead-lock. In that sense, a deadlock-avoidance scheme could increase system throughput.

Compare the main memory organization schemes of contiguous-memory allocation, pure segmentation, and pure paging with respect to the following issues: a. External fragmentation b. Internal fragmentation c. Ability to share code across processes

The contiguous memory allocation scheme suffers from external fragmentation as address spaces are allocated contiguously and holes develop as old processes die and new processes are initiated. It also does not allow processes to share code, since a processes's virtual memory segment is not broken into noncontinguous finegrained segments. Pure segmentation also suffers from external fragmentation as a segment of a process is laid out contiguously in physical memory and fragmentation would occur as segments of dead processes are replaced by segments of new processes. Segmentation, however, enables processes to share code; for instance, two different processes could share a code segment but have distinct data segments. Pure paging does not suffer from external fragmentation, but instead suffers from internal fragmentation. Processes are allocated in page granularity and if a page is not completely utilized, it results in internal fragmentation and a corresponding wastage of space. Paging also enables processes to share code at the granularity of pages.

Consider the dining philosophers problem where the chopsticks are placed at the center of the table and any two of them could be used by a philosopher. Assume that requests for chopsticks are made one at a time. Describe a simple rule for determining whether a particular request could be satisfied without causing deadlock given the current allocation of chopsticks to philosophers.

The following rule prevents deadlock: when a philosopher makes a request for the first chopstick, do not grant the request if there is no other philosopher with two chopsticks and if there is only one chopstick remaining.

A certain computer provides its users with a virtual-memory space of 2^32 bytes. The computer has 2^18 bytes of physical memory. The virtual memory is implemented by paging, the page size is 4096 bytes. A user process generates the virtual address 112123456. Explain how the system establishes the corresponding physical location. Distinguish between software and hardware operations.

The virtual address in binary form is: 0001 0001 0001 0010 0011 0100 0101 0110 Since the page size is 2^12, the page table size is 2^20. Therefore the low-order 12 bits "0100 0101 0110" are used as the displacement into the page, while the remaining 20 bits "0001 0001 0001 0010 0011" are used as the displacement in the page table.

What is the cause of thrashing? How does the system detect thrashing? Once it detects thrashing, what can the system do to eliminate this problem?

Thrashing is caused by underallocation of the minimum number of pages required by a process, forcing it to continuously page fault. The system can detect thrashing by evaluating the level of CPU utilization as compared to the level of multiprogramming. It can be eliminated by reducing the level of multiprogramming.

Given five memory partitions of 100 KB, 500 KB, 200 KB, 300 KB, and 600 KB(in order), how many would each of the first-fit, best-fit, and worst-fit algorithms place processes of 212 KB, 417 KB, 112 KB, and 426 KB(in order)? Which algorithm makes the most efficient use of memory?

First-fit: 212K is put into 500K partition. 417K is put into 600K partition. 112K is put into 288K partition(new partition 288K = 500K - 212K). 426K must wait. Best-fit: 212K is put into 300K partition. 417K is put into 500K partition. 112K is put into 200K partition. 426K is put into 600K partition. Worse-fit: 212K is put into 600K partition. 417K is put into 500K partition. 112K is put into 388K partition. 426K must wait. The best-fit turns out to be the best

Discuss the hardware support required to support demand paging.

For every memory-access operation, the page table needs to be consulted to check whether the corresponding page is resident or not and whether the program has read or write privileges for accessing the page. These checks have to be performed in hardware. A TLB could serve as a cache and improve the performance of the lookup operation.

Is it possible for a process to have two working sets, one representing data and another representing code? Explain.

Yes, in fact many processors provide two TLBs for this very reason. As an example, the code being accessed by a process may retain the same working set for a long period of time. However, the data the code accesses may change, thus reflecting a change in the working set for data accesses.

Consider the following segment table: Segment Base Length 0 219 600 1 2300 14 2 90 100 3 1327 580 4 1952 96 What are the physical addresses for the following logical addresses? a. 0,430 b. 1,10 c. 2,500 d. 3,400 e. 4,112

a. 219 + 430 = 649 b. 2300 + 10 = 3210 c. illegal reference, trap to operating system d. 1327 + 400 = 1727 e. illegal reference, trap to operating system

Consider a logical address space of 32 pages with 1024 words per page mapped onto a physical memory of 16 frames. a. How many bits are required in the logical address? b. How many bits are required in the physical address?

a. 2^5 = 32 + 2^10 = 1024 = 15 bits b. 2^4 = 32 + 2^10 = 1024 = 14 bits

On a system with paging, a process cannot access memory that it does not own; why? How could the operating system allow access to other memory Why should it or should it not?

An address on a paging system is a logical page number and an offset. The physical page is found by searching a table based on the logical page number to produce a physical page number. Because the operating system controls the contents of this table, it can limit a process to accessing only those physical pages allocated to the process. There is no way for a process to refer to a page that it does not own because the page will not be in the page table. To allow such access, an operating system simply needs to allow entities for non-process memory to be added to the process's page table. This is useful when two or more processes need to exchange data -- they just read and write to the same physical addresses(which may be at varying logical addresses). This makes for very efficient interprocess communication.

Consider the deadlock situation that could occur in the dining philosophers problem when the philosophers obtain the chopsticks one at a time. Discuss how the four necessary conditions for deadlock indeed hold in this setting. Discuss how deadlocks could be avoided by eliminating any one of the four conditions.

Deadlock is possible because the four necessary conditions hold in the following manners: 1) mutual exclusion is required for chopsticks, 2) the philosophers hold onto the chopstick in hand while they wait for the other chopstick, 3) there is no preemption of chopsticks in the sense that a chopstick allocated to a philosopher cannot be forcibly taken away, and 4) there is a possibility of circular wait. Deadlocks could be avoided by overcoming the conditions in the following manner: 1) allow simultaneous sharing of chopsticks, 2) have the philosophers relinquish the first chopstick if they are unable to obtain the other chopstick, 3) allow chopsticks to be forcibly taken away if a philosopher has had a chopstick for a long period of time, and 4) enforce a numbering of the chopsticks and always obtain the lower numbered chopstick before obtaining the higher numbered one.

Assume that you are monitoring the rate at which the pointer in the clock algorithm(which indicated the candidate page for replacement) moves. What can you say about the system if you notice the following behavior: a. pointer is moving fast b. pointer is moving slow

If the pointer is moving fast, then the program is accessing a large number of pages simultaneously. It is most likely that during the period between the point at which the bit corresponding to a page is cleared and it is checked again, the page is accessed again and therefore cannot be replaced. This results in more scanning of the pages before a victim page is found. If the pointer is moving slow, then the virtual memory system is finding candidate pages for replacement extremely efficiently, indicating that many of the resident pages are not being accessed.

Explain the difference between internal and external fragmentation.

Internal fragmentation is the area in a region or a page that is not used by the job occupying that region or page. This space is unavailable for use by the system until that job is finished and the page or region is released.

A simplified view of thread states is Ready, Running, Blocked where a thread is either ready and waiting to be scheduled, is running on the processor, or is blocked. Consider a thread that may be in one of these three states on a computer with virtual memory. Assuming a thread is running, (1) will the thread change state if it incurs a page fault? (2) what about a TLB-miss but resolved in the page table?

On the page fault the thread is set to blocked. On a TLB-miss, the thread continues running.

Consider the following process for generating binaries. A compiler is used to generate the object code for individual modules, and a linkage editor is used to combine multiple object modules into a single program binary. How does the linkage editor change the binding of instructions and data to memory address? What information needs to be passed from the compiler to the linkage editor to facilitate the memory binding tasks of the linkage editor?

The linkage editor has to replace unresolved symbolic addresses with the actual addresses associated with the variables in the final program binary. In order to perform this, the modules should keep track of instructions that refer to unresolved symbols. During linking, each module is assigned a sequence of addresses in the overall program binary and when this has been performed, unresolved references to symbols exported by this binary could be patched in other modules since every other module would contain the list of instructions that need to be patched.

Consider a demand-paging system with the following time measured utilizations: CPU utilization = 20% Paging disk = 97.7% Other I/O devices = 5% For each of the following, say whether it will(or is likely to) improve CPU utilization. Explain your answers. a. Install a faster CPU b. Install a bigger paging disk. c. Increase the degree of multiprogramming. d. Decrease the degree of multiprogramming. e. Install more main memory. f. Install a faster hard disk or multiple controllers with multiple hard disks. g. Add preparing to the page fetch algorithms. h. Increase the page size.

The system obviously is spending most of its time paging, indicating over-allocation of memory. If the level of multiprogramming is reduced resident processes would page fault less frequently and the CPU utilization would improve. Another way to improve performance would be to get more physical memory or a faster paging drum. a. No b. No. c. No. d. Yes. e. Likely to improve CPU utilization as more pages can remain resident and not require paging to or from the disks. f. Also an improvement, for as the disk bottleneck is removed by faster response and more throughput to the disks, the CPU will get more data more quickly. g. Again, the CPU will get more data faster, so it will be more in use. This is only the case if the paging action is amenable to prefetching(i.e., some of the access is sequential). h. Increasing the page size will result in fewer page faults if data is begin accessed sequentially. If data access is more or less random, more paging action could ensue because fewer pages can be kept in memory and more data is transferred per page fault. So this change is as likely to decrease utilization as it is to increase it.

Consider the parameter \Delta to define the working-set window in the working-set model. What is the effect of setting \Delta to a small value on the page fault frequency and the number of active(non-suspended) processes currently executing in the system? What is the effect when \Delta is set to a very high value?

When \Delta is set to a small value, then the set of resident pages for a process might be underestimated, allowing a process to be scheduled even though all of its required pages are not resident. This could result in a large number of page faults. When \Delta is set to a large value, then a process's resident set is overestimated and this might prevent many processes from being scheduled even though their required pages are resident. However, once a process is scheduled, it is unlikely to generate page faults since its resident set has been overestimated.

What is the copy-on-write feature and under what circumstances is it beneficial to use this feature? What is the hardware support required to implement this feature?

When two processes are accessing the same set of program values(for instance, the code segment of the source binary), then it is useful to map the corresponding pages into the virtual address spaces of the two programs in a write-protected manner. When a write does indeed take place, then a copy must be made to allow the two programs to individually access the different copies without interfering with each other. The hardware support required to implement is simply the following: on each memory access, the page table needs to be consulted to check whether the page is write protected. If it is indeed write protected, a trap would occur and the operating system could resolve the issue.

Program binaries in many systems are typically structured as follows. Code is stored starting with a small fixed virtual address such as 0. The code segment is followed by the data segment that is used for storing the program variables. When the program starts executing, the stack is allocated at the other end of the virtual address space and is allowed to grow towards lower virtual addresses. What is the significance of the above structure for the following schemes: a. contiguous-memory allocation b. pure segmentation c. pure paging

a. Contiguous-memory allocation requires the operating system to allocate the entire extent of the virtual address space to the program when it starts executing. This could be much larger than the actual memory requirements of the process. b. Pure segmentation gives the operating system flexibility to assign a small extent to each segment at program startup time and extend the segment if required. c. Pure paging does not require the operating system to allocate the maximum extent of the virtual address space to a process at startup time, but it still requires the operating system to allocate a large page table spanning all of the program's virtual address space. When a program needs to extend the stack or the heap, it needs to allocate a new page but the corresponding page table entry is preallocated.

Assume a program has just referenced an address in virtual memory. Describe a scenario how each of the following can occur: (If a scenario cannot occur, explain why.) a. TLB miss with no page fault b. TLB miss an page fault c. TLB hit and no page fault d. TLB hit and page fault

a. Has been brought into the memory but has not been removed from the TLB b. TLB miss and page fault page fault has occurred c. Most likely a recent reference d. The TLB is a cache of the page table. If an entry is not in the page table, it will not be in the TLB

Consider a system that uses pure demand paging: a. When a process first start execution, how would you characterize the page fault rate? b. Once the working set for a process is loaded into memory, how would you characterize the page fault rate? c. Assume a process changes its locality and the size of the new working set is too large to be stored into available free memory. What are some options system designers could choose from to handle this situation?

a. Initially quite high as needed pages are not yet loaded into memory. b. It should be quite low as all necessary pages are loaded into memory. c. (1) Ignore it; (2) get more physical memory; (3) reclaim pages more aggressively due to the high page fault rate.

Consider the following snapshot of a system: Allocation MAX Available P0 A B C D A B C D A B C D P1 0 0 1 2 0 0 1 2 1 5 2 0 P2 1 0 0 0 1 7 5 0 P3 1 3 5 4 2 3 5 6 P4 0 6 3 2 0 6 5 2 P5 0 0 1 4 0 6 5 6 Answer the following questions using banker's algorithm: a. What is the content of the matrix Need? b. Is the system in a safe state? c. If a request from process P1 arrives for (0,4,2,0), can the request be granted immediately?

a. The values of Need for processes P0 through P4 respectively are (0,0,0,0),(0,7,5,0),(1,0,0,2),(0,0,2,0),(0,6,4,2) b. Yes. With Available being equal to (1,5,2,0) either process P0 or P3 could run. Once process P3 runs, it releases its resources, which allow all other existing processes to run. c. Yes it can. This results in the value of Available being (1,1,0,0). One ordering of processes that can finish is P0, P2, P3, P1, and P4.

Assuming a 1 KB page size, what are the page numbers and offsets for the following address references(provided as decimal numbers): a. 2375 b. 19366 c. 30000 d. 256 e. 16385

a. page = 1; offset = 391 b. page = 18; offset = 934 c. page = 29; offset = 304 d. page = 0; offset = 256 e. page = 1; offset = 1


Ensembles d'études connexes

constructing your future test review

View Set

Ch. 1 Intro. to Nursing Quiz Questions

View Set

Ch 3: Cultural and Spiritual Issues Related to Mental Health Care

View Set

BUS 315: Chapter 7: Strict Liability and Product Liability

View Set