|
GOALS
To get familiar with the
processes (and threads) and process
management concepts.
To understand how the processes
are created, scheduled and finally
removed from the system.
To study the basic principles
of I/O and buffering.
To get familiar with directory
and file management and the duties of
the OS when a process uses files.
Key words:: PCB, process states, I/O methods, device dependent and device independent I/O, file management, disk management
TEXT IN COURSE BOOK
SLIDES and OTHER MATERIALS
Other Materials: Tanenbaum A.S.: Modern Operating Systems. 2nd ed. 2001. Pages 71-94,269-300, 399-408, 445-448.
EXERCISES A-C
The report must be returned on paper latest on Friday 29.10. into the mailbox beside the room D225 (before 12 o'clock). You can also leave the report to the teacher during the small group meeting on Wednesday 13.10.
Before the first meeting: Study the following questions carefully. Think about possible solutions. Write down all your ideas, results, problems, and unclear parts. 1. meeting: In a study group, study the exercises together. Think and discuss about what issues you already know, what items you need to find more information about, what information is needed, etc. You can consult the teacher of the small group session, but he will not solve the problems for you. He can gie you hints and show the right way for solveing the problem, if you are totally lost. Between the two meetings: You may need to discuss together between the meetings to write your report. These discussion you need to organise yourselves. You may wish to use personal meetings at Exactum or somewhere else, use e-mail, irc, webCT (if you want to use webCT, please contact Tiina Niklander). You are expected to write your report before the second meeting. 2. meeting: Study groups present their solutions and report contents to other groups during the meeting. After the 2. meeting: If you feel that you need to modify your report, you'll have two days after the meeting to finalise your report. For example, you may want to add/change/correct some items in your report based on the presentations during the meeting. Please notice, that you'll have ONLY two days for this. |
A - EXERCISES
Each Team: Give your solutions to the following 6 exercises.
|
3.1 - PROCESSES AND THREADS
a) Explain the concepts of a process and a thread. Compare the concepts with each other. What are the benefits of using threads?
b) Assume that kernel level threads are available. The OS creates a Process Control Block for each process, and a Thread Control Block for each thread spawned from the process. Explain what kind of information is kept a) in process control block and b) in thread control block. Tell also briefly when and for what purpose the OS uses the information.
c) How does the bookkeeping differ, if the threads are implemented in user level.
3.2 - 3 JOBS TO DO
Consider a system that has 3 exactly similar jobs. Each one has a loop including 500 ms of calculations and thereafter 150 ms of I/O. The loop is repeated 1000 times.
a) How long does it take to run these jobs if everything is done serially (uniprogramming system)? What is the average turnaround time and the CPU utilization in this case?
b) The same processes are run in a time-shared multiprogramming system. The OS dispatches CPU in 100 ms timeslices. If the process can't use a whole timeslice, it gets next time a new timeslice. Assume that the I/O:s can be done parallel, and they don't interfere with each other. Create a timing diagram. How long does it take to run these jobs? What is the average turnaround time and CPU utilization in this case?
c) Consider a two processor SMP system running the same prosesses as in b). Create a diagram of the process execution. How long does it take to complete these processes? What is the average turnaround time and the CPU utilization?
3.3 - RECOVERY
The file system of a disk may crash due to a physical failure or software error. The the file system cannot be used normally, for example the files are lost.
Consider a hierarchical file system (foe example FAT) where the file allocation is done using a table. What would happen if the bitmap or free list containing the information about free disk blocks was completely lost due to a crash? Is there any way to recover from this disaster, or is it bye-bye disk? What kind of alternatives can you think about? Does it matter what is the used structure for storing the information about the free blocks?
3.4 - FAT AND FILE USAGE
The FAT file system considers the disk as a one dimensional array of blocks. The blocks are numbered so that the blocks on the uppermost surface of the outermost track are numbered first, then the numbering continues with the outermost track of the second uppermost surface and so on. When all surfaces are numbered, then the numbering goes to the second outermost track of the uppermost surface, and so on.
Suppose that a disk has two surfaces (0..1) that both have 80 tracks (numbers 0..79). Each track is divided into 18 sectors, which are numbered from 1 to 18. The size of a sector is 512 bytes, which is also the block size used by the FAT file system for this disk.
Few blocks from the beginning of the disk are reserved for DOS: 1 block for boot record, 18 blocks for file allocation table (and for its copy) and 14 blocks for the root directory.
a) What is the maximum capacity of this disk?
b) What percentage of the total space is for datablocks?
c) The entry in the DOS directory contains the file name, some attributes and the number of the first block allocated for the file. The next block numbers can be found by following the chain in the file allocation table. Let's assume that the first block for file JEMMA is in block 44, and the contents of the FAT is following:
43: 44: 45 45: 46 46: 50 47: 48: 49: 50: 51 51: 52 52: 60
What is the corresponding surface number, track number and sector number for the byte 2152 in file JEMMA?
3.5 - OPEN - USE - CLOSE
a) In some systems the process does not need to open files beforehand (e.g. by calling fd=open(file_name, mode)). The file is opened automatically by the OS when it is used for the first time. Similarly the process does not need to close the file (e.g by calling close(fd)). The file is closed automatically when the process finishes. Could you find any advantages / disadvantages in this manner compared to the more usual way, where the files are opened before the usage and can be closed whenever wanted.
b) When a process opens a file, it has to give the file name and the usage mode (e.g. read / write / append) as parameters for the operating system. How does the OS find the file? How does the OS check that the usage mode is legal for this specific process?
c) How many disk reads are needed in the worst case, if the UNIX process wants to read the byte 13423956 from the file /usr/ville/data? Assume that the inode for the root directory is already in the main memory, and that each directory is small enough to fit into a one block.
3.6 - MANAGING AN I/O CALL
A process makes a system call READ to get one integer value (4 bytes) into a variable MJA. The process has earlier opened the file by OPEN system call. Assume that the OS has not prefetched anything, and therefore the value must be read from the disk.
What kind of parameters the process has to pass to the operating system? How are the parameters passed?
How does the operating system find the information specific to this file?
How does the operating system know which of the file's blocks has to be read into memory? When the block number is clear, the hardware independent part of file system hands the I/O-request to the device driver. What kind of information must be handed to the driver?
The drive calculates the physical address (surface number, track number and sector number) and passes them to the device controller. What else has the device driver tell to the controller (DMA-transfer) and how are these parameters passed?
Since the controller is capable to deliver the bytes directly into memory, the CPU can run other processes meanwhile. How does the OS notice that the transfer is ready? What are the final operations that the OS has to complete before the requesting process is moved back to Ready queue? (Hint: Where did the controller transfer the data?)
B - SELECT YOUR FAVOURITE REVIEW QUESTIONS Each team: List five review questions that you consider most relevant for this section, and explain why it is important to understand the answers. A good review question requires understandin a lot about the issue. A question that only asks about some very small details is not a very good review question. If there are areas that would need more detailed explanations, please give a hint. |
C - EVALUATION Each team: Please evaluate your teams work as well as your own work using the following pdf form (in Finnish). The form will be handed to the team in the small group session. The evaluation has two goals: (1) to collect information about the exercises and study groups, and (2) to help study groups to make their work even better. We appriciate short answers that give the essentials in a compact form. Please try to be open minded. Answer to each question and give also your reasonings. |
|