Answer: 11, 15, 16, 8, 3, 1
File name | First block | Size in bytes --------------------------------------- AA 5 1350 BB 7 2200(The other information in the directory is omitted.) The current state of the FAT is
0 -- FREE 1 -- FREE 2 -- -1 3 -- 4 4 -- -1 5 -- 2 6 -- FREE 7 -- 3 8 -- FREEThe system uses a block size of 1 Kbyte. What is the last block of file BB? How many bytes of that block are used? (Useful fact: 1K=1024).
Answer: The blocks of BB are 7, 3, 4. Since BB has length 2200 and blocks 7 and 3 hold 2048 bytes, there are 152 bytes used in block 4.
A. 3*1024+50 = 3122.
B. Any virtual address between 2048 and 3071 or between 4096 and 5119.
Answer: In swapping, a process is entirely removed from main memory and its state is stored on disk. Swapping is used in an OS that uses variable-length partitions in the case there are active processes that are ready to run but do not fit into any free segment of main memory (either because the total memory requirements of the active processes is too large, or because space has been wasted in external fragmentation.)
In an OS that uses pages, swapping may be used when the sum of the working set sizes for the processes currently in memory is greater than the size of physical memory. When this happens, thrashing -- frequent page faults -- is almost inevitable, as the processes are competing for a resource (frames) that is inadequate to their combined needs. The only solution in such a case is to swap out (suspend) one or more of the processes.
Answer: (Note: this is a lot more detail than I would expect on an exam answer. Also, the exact steps and the division of the steps among components of the system can vary a lot from one system to another.)
The device-independent software passes to the device driver the number of bytes to be read, the address in user space to read them into, and the file pointer. It then traps to the kernel. The kernel blocks the process and calls the device driver from the top. The device driver determines that the next byte is on a block B not in memory. It finds the address of B from the i-node (presumably in memory). It issues a request to the device controller to read B into memory. The device controller translate the block number of B into a set of consecutive sectors on a track, and instructs the actual disk to read those sectors. The disk moves the arm to the correct track, waits for the disk to rotate to the proper sectors, and reads the information, putting the output into the disk controller's buffer. The disk controller issues a interrupt. The interrupt handler in the kernel sends control to the bottom of the disk driver. The disk driver transfers the block of data from the disk contoller's buffer to the file cache, and transfers the byte of data to the specified address in user space. The kernel unblocks the process and schedules it to run. The device-independent software finds its data where it expects, and returns control to the user process.
B. Name one preemptive scheduling algorithm and one non-preemptive
scheduling algorithm. (Just the names; you do not have to describe them.)
Answer: Of the scheduling algorithms we have discussed, shortest remaining time first, round robin, selfish round robin are preemptive; first come first served and shortest job first are non-preemptive.
C. Even if all jobs are CPU-bound, a preemptive scheduler may
give a better average turnaround time than a non-preemptive scheduler.
Give an example that illustrates this.
Answer: Suppose that process P, with one CPU burst of 100 sec, enters at time 0, and the process Q, with one CPU burst of 1 sec, enters at time 1. Then a non-preemptive scheduler will run first P from time 0-100 and then process Q from time 100-101 for an average turnaound time of 100. By contrast, assuming a small quantum and ignoring time lost to context switches, a preemptive scheduler will complete process Q at time 3 and process P at time 101, for an average turnaround time of 52.
Answer: The R bit is 1 if the page has been referenced since the last clock tick. The M bit is 1 if the page has been modified since it was read in. At each machine instruction, the R bit for any page of any virtual address referenced is set to 1. The M bit is set to 1 if the process writes to that page. The R bit is reset to 0 at each clock tick. The M bit is reset to 0 when the page is written out to disk. In the NRU algorithm, pages are divided into 4 categories:
Answer: When a polymorphic virus copies itself for insertion into some new location, it makes changes to its internal code that do not affect its functionality (e.g. adding no-ops; making an inconsequential change to registers used; changing the way in which a given operation is done; etc.) This makes it harder for a virus detector to find the virus using simple pattern matching.