Operating Systems Final

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

In terms of demand paging, what is meant by temporal locality?

If a page is needed now, it will probably be needed again soon. For example, a set of instructions may be executing in a loop, or the data may need to be accessed repeatedly for a period of time.

What are the disadvantages of Linked Allocation for storing a file?

If only one block in the middle of the file needs to be read, all the blocks before it must be read to get to that middle block. Also, if a block gets damaged, the rest of the file is lost. Finally, it can potentially require many seeks to find the blocks if they are not stored contiguously.

The swapper, sometimes known as the medium-term scheduler, swaps processes between physical memory and swap space, also called backing store. Under what conditions would a process that is in swap space be swapped back into physical memory?

If the CPU scheduler chooses a process to run, and it is in swap space, it must be swapped back into physical memory before it can run.

What happens on a reference to the page table if the bit is invalid?

If the entry is invalid, the page is not in memory, so a page fault must occur to bring the page into memory and update the page table before the page can be accessed.

What happens on a reference to the page table if the bit is valid?

If the entry is valid, the page is in memory, and the page table entry contains the frame number, so use that frame number to generate the physical address.

How can thrashing be avoided by monitoring the page-fault frequency of a process?

If the process is page faulting too much, its entire working set is not in memory, so give it an additional frame.

If a resource allocation graph does not contain a cycle, there is no deadlock. If it does contain a cycle, is there deadlock or not? Explain.

If there is a cycle, there may or may not be deadlock. If there are only singles instances of all resources, then there is deadlock. If there are multiple resource instances, there is the possibility of deadlock.

Describe the C-SCAN disk head scheduling, and draw a diagram to illustrate your explanation.

In C-SCAN, the disk head starts at one end of the disk and moves toward the other end, servicing requests as it moves. Once it reaches the other end, it returns to the beginning and starts over, but it does not service requests as it returns to the beginning.

What is RAID 0 (Striping) and why is it useful?

In RAID 0, data is split ("striped") across both drive, with part of the data written to one drive while the other part is written to the other drive. Since both parts are written simultaneously, RAID 0 provides improved performance.

What is RAID 1 (Mirroring) and why is it useful?

In RAID 1, data on one drive is completely copied (mirrored) onto the drive. It provides fault tolerance - if one drive fails, the data can be restored from the other drive.

In dynamic relocation, the Memory Management Unit (MMU) translates logical addresses into physical addresses as the program runs. How does it do this? Be specific.

While the process is loaded into memory at some address, that address is stored in the Base Register in the MMU. The MMU then takes any logical addresses that it receives, adds that base value to the address, which produces a physical address.

With paging in general, the Memory Management Unit uses the Page Table when translating logical addresses to physical addresses. How does this translation change with demand paging?

With demand paging, it has to check the valid-invalid bit associated with the page in the page table. If that bit is valid, then it uses the entry to find the frame number as before. However, if that bit is invalid, the page is not in memory, so a page faulty occurs to bring it into memory. Additionally, demand paging adds a modified/dirty bit, and usually adds a TLB to improve performance.

What is the relationship between a "sector", "track" and "block" (or logical block)? (5 points)

A track is a ring, composted of small storage units called sectors. A block is a set of sectors, and is used by the file system to store pieces of a file.

One of the four conditions necessary for deadlock is hold and wait. What is meant by hold and wait in this context?

A process is holding at least one resource and waiting to acquire one or more additional resources that are held by other processes.

In the context of Deadlock Avoidance, what is a safe state?

A safe state is a state in which there exists a sequence of resource allocations that will allow all processes to compete their execution.

In dynamic relocation, the Memory Management Unit (MMU) provides protection. What does protection mean in this context, and why is it important.

A process can only aces its own memory space; it cannot access the memory space of other processes or the operating system. That is important to prevent accidental or malicious damage to another process.

What change(s) need to be made to the page table to support demand paging, and why?

A valid-invalid bit must be added to distinguish between pages that are in memory (valid) and pages that are not in memory (invalid). A modified / dirty bit should also be added to distinguish between pages that have been modified versus those that have not.

What is the distinction between a partition and a volume?

A volume is a partition that contains a file system.

What are the advantages and disadvantages of linked allocation over contiguous allocation of disk space?

Advantages: Since any free space can be used, there is no need for complex allocation algorithms such as first-fit or best-fit. Further, linked allocation does not suffer from external fragmentation like contiguous allocation.Disadvantages: If the file is spread out across the disk, access is less efficient. Following the links adds overhead. If a link gets damaged, the entire rest of the file is lost.

Which File Control Blocks are stored on the disk, and where on the disk are they stored?

All File Control Blocks are stored on disk; they are stored in a table (called the "i-list" in UNIX terms) near the beginning of the volume.

A page fault is a type of exception. What is an exception?

An exception is similar to an interrupt, but instead of being generated by a hardware device, it is caused by a failure in the execution of an instruction.

RAID 0 (striping) is intended to improve performance by using two disk drives and writing to both simultaneously. How does this improve performance? (5 points)

Because only half of the data is written to each drive, essentially cutting the time to write a file in half, or doing the same with reading a file.

In an operating system, we are concerned about deadlock involving "resources". List three examples of operating system resources that we may be concerned about in this context.

CPU cycles, memory space, I/O devices, file, printer, network connection, mutex locks.

Define the RAID concepts of striping (RAID 0) and mirroring (RAID 1).

In striping, each piece of data is distributed over multiple drives to improve disk access time. In mirroring, each piece of data is duplicated in its entirety on another drive to provide redundancy in the case a drive fails.

Deadlock prevention tries to eliminate deadlock by eliminating one of the four conditions. How can hold and wait be eliminated?

It can be eliminated by ensuring that when a process requests a resource it is not holding any other resources. That would either require requesting all resources at once (at the beginning of the program or when the first resources is needed), or releasing any current resources and reacquiring it along with any new resources at the same time. This technique is not effective since it is difficult to know in advance what resources will be needed, and wastefully ties up unneeded resources, and it allows starvation.

The First-Come First-Served (FCFS) disk scheduling is easy to implement, but can be very inefficient. Explain. (5 points

It does not consider seek time, so it could seek widely back and forth across the disk, especially if one set of accesses are on the inner tracks and another set of accesses are on the outer tracks

The MMU contains a Base Register. What is stored in this register?

It holds physical address where the process is loaded in memory — the "base" of the process in memory.

One possible solution for deadlock is deadlock detection plus recovery, but recovery is problematic. Explain.

It is difficult to know which process to terminate, and it may be difficult for that process to restart after it has been terminated.

With contiguous allocation, the entire process must be placed into memory as one contiguous unit using either fixed-sized partitions or dynamic partitions. Why is this a problem?

It may be difficult to find a large enough space in memory.

One of the four necessary conditions for deadlock is "hold and wait". What does it mean for a process to "hold" a resource?

It means the process requested that resource, and now the resource has been assigned to the process for it to use.

What is the point of implementing a file system in layers, with a logical file system, file organization module, basic file system, and device drivers? (5 points)

It separates the functionality so that one layer knows about directories, another files, another the blocks that make up files, and another the details of the sectors. That allows modular design, debugging, etc.

Consider the two diagrams below that show fixed-sized partitions. What advantage does the one on the right have over the one on the left? What complications would it add?

It supports larger processes than the one on the left, but it adds the need for an algorithm such as first-fit or best-fit to choose the appropriate partition.

Consider when demand paging starts loading a process. Within a short period of time, how many pages would the process likely have in memory, and why? (5 points)

It would probably have at least four pages - at least one each for instructions, static data, heap, and stack.

Since all the File Control Blocks are stored on the disk, what is the benefit of storing File Control Blocks for open files in the System-Wide Open File Table?

Looking up information in a File Control Block in memory is much faster than looking up information in a File Control Block on disk. Essentially, the table is caching active File Control Blocks.

List the 4 necessary and sufficient conditions for deadlock.

Mutual exclusion No preemption Hold and wait Circular wait

Does Paging suffer from external fragmentation? Explain

No. External fragmentation is wasted space outside partitions, but since all the frames are the same size, all of them are unusable.

The basic idea of deadlock detection is to look for deadlock occasionally. Assuming deadlock is found, what must be done to break the deadlock?

One or more of the deadlocked processes must be terminated.

Which type of RAID would be better for crucial files that you do not want to lose, and why?

RAID 1 (Mirroring) would be better because it always provides a live backup.

Briefly describe the SCAN, C-SCAN, and C-LOOK disk scheduling algorithms.

SCAN — the disk read/write head starts at one end of the disk, and moves toward the other end, servicing requests as it goes. When it gets to the other end of the disk, the head movement is reversed, and it services requests as it returns. Then this process repeats. C-SCAN — the disk read/write head starts at one end of the disk, and moves toward the other end, servicing requests as it goes. When it gets to the other end of the disk, it immediately returns to the beginning of the disk without servicing any requests on the return trip. Then this process repeats. C-LOOK — the disk read/write head starts at the request closest to one end of the disk, and moves toward the other end, servicing requests as it goes. When it gets to the last request in the direction it is moving, it immediately returns to the request closest to the beginning of the disk without servicing any requests on the return trip. Then this process repeats.

The access time for a disk drive is dominated by the seek time and the rotational latency. How can each of these be reduced? (5 points)

Seek time can be reduced by using a good disk scheduling algorithm such as FCFS or LOOK. Rotational latency can be reduced by buying a faster disk drive (with higher RPM) and by allocating file blocks contiguously.

Consider the five security violation categories discussed in class. Which one fits a hacker stealing the credit card info from a big store, and which one fits a hacker replacing a store's main web page with a political post?

Stealing credit card information would be breach of confidentiality. Replacing a web page would be either breach of integrity (modifying data), breach of availability (Destroying data) and possibly denial of service (since it's preventing use of that web page).

The File Control Block contains most of the information about a file, but does not contain the file name. Where is the file name stored, and why is it not stored in the File Control Block?

The file name is stored in the directory. It is stored there because, with aliases / shortcuts, multiple directories could refer to the file, possibly using different names for it.

If there isn't room enough for all processes, some processes can be swapped out to make room. When one of those swapped-out processes needs to run again, the operating system must swap it back in (into memory). How is the CPU scheduler involved in this procedure?

The CPU scheduler is choosing the process to run, and if that process is swapped out, the CPU scheduler calls the swapper to bring it back in, and possibly to swap one or more processes out to make room.

What information is stored in a Directory?

The Directory is a table of file names and pointers to the File Control Block / inode that represents the file.

How does the MMU use the value in the Base Register to produce the physical address?

The MMU adds the Base Register value to a logical address in the process to get a physical address.

In what way(s) are LOOK and C-LOOK an improvement over SCAN and C-SCAN? (5 points)

The SCAN versions go past the "last" request all the way the ends of the disk, whereas the LOOK versions go only as far as the last request, avoiding that unnecessary extra seek time.

Segmentation is implemented using a Segment-Table and a Segment-Table Base Register. Where are these two items found?

The Segment Table is stored in the Process Control Block, and the Segment-Table Base Register is inside the Memory Management Unit (MMU)

Each platter surface in a hard drive is formatted with a number of tracks, each of which contains a number of sectors. How does the read/write head reach a particular track and sector?

The arm moves the head over the desired track, and then the head waits for that sector to rotate under the head.

What is the role of the valid-invalid bit in the page table? What happens if the bit if "valid"? What happens if it is "invalid"?

The bit specifies whether or not the page is in memory. If the bit is "valid", the page is in memory, and is in the frame referenced by the page table. If the bit is "invalid", the page is not in memory, so a page fault occurs and the page must be brought into memory.

Each bootable partition on a disk begins with a boot block, super block, and set of inodes (in the ilist), but then the rest of the consists of a set of blocks, some of which contain part of a file or director, and some of which are free. How does the OS find the blocks that make up a file, and how does the OS find the blocks that are free?

The blocks that make up a file are pointed to by the file's File Control Block (inode), and the free blocks are pointed to by the super block

Consider the C program below, which copies anything typed after a program name to a buffer. What is the problem with this code? #include <stdio.h> #define BUFFER_SIZE 256 int main(int argc, char *argv[]) { char buffer[BUFFER_SIZE]; if (argc < 2) return -1; else { strcpy(buffer,argv[1]); return 0; } }

The buffer only holds 256 characters, so if the input is larger than 256 characters it will overflow the buffer.

Consider paging versus contiguous memory allocation. What advantages does paging provide over contiguous memory allocation?

The entire process does not have to be contiguous, code or data can be shared between processes, there are no complex memory allocation methods (e.g., first-fit, best-fit) needed, and there is no external fragmentation.

Summarize what happens when a page fault occurs. (Ignore the possible need for page replacement in your answer.)

The exception handler for the page fault is called. That hander saves the process state, calls the Pager, restores the process state, and the process continues execution. The Pager finds a free frame, brings the page into memory, and updates the Page Table (including the valid bit).

What is the basic idea of Deadlock Prevention and why does it work?

The four conditions for deadlock are necessary for deadlock to occur, so if all four do not occur, there is no deadlock. The idea behind Deadlock Prevention is to eliminate one of those conditions and therefore prevent deadlock.

Consider the Resource Allocation Graphs shown below. Why does the arrow in the left figure go to the outer box but the arrow in the right figure comes from an inner box?

The left figure is illustrating a request edge, which is to the resource as a whole since any of the resource instances would be acceptable. The right figure is illustrating the specific instance of the resource that has been assigned to the process.

Segmentation is very similar to contiguous allocation in the sense that it still requires searching to find an unused space in memory and can still have fragmentation problems. However, instead of keeping the process whole, it divides it into smaller pieces, called segments. Why is this an improvement.

The main reason is that it's easier to fit a number of smaller pieces into free spaces in memory than the much larger entire process. As a secondary reason, segmentation would allow processes to share a code or data segment between the two processes.

The main idea behind virtual memory and demand paging is to only load program code and data when it is needed. Why is this an advantage

The operating system does not waste time loading code / data pages that are not needed, and context switches are quicker (less I/O for disk accesses). With part of each processes in memory, more processes can be loaded and share the memory. Finally, this allows processes that are larger than physical memory to still run.

The key idea behind virtual memory and demand paging is to only load pages as needed - on demand. Why is this an advantage?

The operating system does not waste time loading code / data pages that are not needed. With part of each processes in memory, more processes can be loaded and share the memory. Finally, this allows processes that are larger than physical memory to still run.

Briefly explain how paging translates a logical address into a physical address.

The page number is used as an index into the page table, where the frame number is found. That frame number is then combined with the displacement from the logical address to build the physical address.

If the page considered for replacement has a reference bit of 0, the page is replaced. What happens if the page has a reference bit of 1?

The reference bit is set to 0, and the next page is considered. Essentially, the page gets a "second chance" and is replaced the next time it is scanned.

Segmentation breaks a process up into a collection of segments. What criteria are used to determine what is in each segment?

The segments come from the program, and are logical units within the program, such as the code, data, and the stack. Segments may also come from portions of the code, such as individual procedures or functions, or portions of the data, such as an array.

In an operating system, we are concerned about deadlock involving "resources". Consider a laptop with four CPU cores. Are these multiple instances of one resource, or separate resources? Explain.

These are multiple instances of one resource (CPU core) because we consider them to be interchangeable with no significant distinction between them. If it was necessary to treat them differently for some reason, then they would be consider separate resources.

What is being illustrated by the figure below? Be specific, and answer in your own words - do not copy text from the slide.

This figure is illustrating static relocation, with the process being loaded into memory at address 1200. Every instruction that referred to an address, such as the Jump and Load instructions, must now have 1200 added to their address so they will address the proper location.

Suppose someone finds a program on the Internet that they think is useful and install it, and it does seem useful, but they later find out that it accessed their address book and started sending spam email to all their friends. What type of program threat is this? Explain

This is a trojan horse - a program that does something legitimate, but also has hidden malicious code

If a process's entire working set can be kept in memory, would there be any thrashing? Explain. (5 points)

Thrashing occurs when a process has not been allocated enough frames in memory to keep all the pages it needs at the moment. The pages it's currently working with and needs to keep in memory is its working set, so no, if it can keep its working set in memory there would not be any thrashing.

In the Banker's Algorithm for deadlock avoidance, we define the system as being in a "safe state" if there exists a sequence of all processes in the system such that, for each process, the resources that the process can still request can be satisfied by the currently available resources plus resources held by all the earlier processes in the sequence. As we try to determine this sequence of processes, what do we do if we find a process that has resource needs greater than the available resources?

We assume that it has to wait until sufficient resources are available, and if we run this process it may request more resources than we have available and put the system in an unsafe state, so we move on to examine the next process.

In terms of page/fame replacement, what is "global replacement", and what problem does it have?

With global replacement, a process can replace any frame, including a frame belonging to any process. As a result, a process's execution time can vary depending on whether other processes have replaced some of its frames, and a process may not have the pages that it "needs" due to some other process taking those pages, which can in turn lead to thrashing.

In terms of page/fame replacement, what is "local replacement", and what problem does it have?

With local replacement, a process can only replace one of its own frames, not a frame belonging to another process. The main problem is that it may need more frames than it has, so there would need to be some mechanism to increase its number of frames. A related problem is that it may need less frames than it has, so it is wasting memory space, so there would need to be some mechanism to decrease its number of frames.

What problem does the Translation Lookaside Buffer (TLB) solve, and how does it solve that problem?

With paging, every memory reference requires an additional memory reference to access the page table, which doubles the memory access time. The TLB solves that problem by caching sets of page numbers and frame numbers, and it is much faster to access the TLB than it is to access memory to search the page table.

The four conditions that characterize deadlock are mutual exclusion, no preemption, hold and wait, and circular wait. If the system is deadlocked, will all four of these conditions hold? Answer Yes or No, and then explain.

Yes, since these conditions are necessary for deadlock.

Linked Allocation, or Linked Allocation with a FAT, has the advantage that any free space on the disk can be used, so there is no external fragmentation. Would there still be any advantage to storing file blocks contiguously if possible? Explain.

Yes. If the blocks can be store contiguously, the seek time would be eliminated or reduced, and then the blocks just rotate under the disk head one by one.

Consider the figure below, which shows the result of using the FIFO page replacement algorithm on a reference string. (10 points) a). What is being shown in the leftmost box with a reference string value of 3? Be specific, and refer to the FIFO algorithm. (5 points) b). What is being shown in the rightmost box with a reference string value of 3? Be specific, and refer to the FIFO algorithm. (5 points

a). Page 3 is being referenced, and is not in memory, so there is a page fault to bring it into memory. Since memory is full, a page must be replaced. The pages in memory are 2, 0, and 1, and of those 0 came into memory first so it is replaced by page 3. b). Page 3 is being referenced, and it is in memory, so no page fault or page replacement are needed.

In what way(s) are swapping and demand paging similar, and in what ways are they different? Do not define the two terms, but give a clear answer of how they are similar and different - both do A and B, but swapping does X while demand paging does Y. (10 points)

a. How are they similar? (5 points) Both move program code and data to swap space when memory is full and a process needs to be brought into memory to run. b. Continuing the previous question, how are they different? (5 points) Swapping moves the entire process, while demand paging only moves individual pages

contiguous allocation

each file occupies a set of contiguous blocks


Conjuntos de estudio relacionados

森林之王 The King of Forest # 2

View Set

16 PROPERTY VALUATION AND APPRAISAL

View Set

The Legislative Branch: Introduction

View Set

EGEE 101 Exam 2 Review Questions

View Set

ACG 2071 Test 2- Concepts/ Definitions Only

View Set

CH. 3 practice homework questions

View Set

SCM 354 Chapter 19 Performance Measurement and Evaluation

View Set