COMP SCI 3SH3: Operating System Concepts; Term 2 (Winter 2006)
Test 1 January 30, 2006; Time: 50 Minutes ; 10 QuestionsInstructor: Dr. Kamran Sartipi
Question 1 (operating systems): [12 marks]
What are the main characteristics of the following types of operating systems in terms of resource utilization and the type of services they provide?
In general different resources include: CPU, memory, and I/O. 1) Batch processing systems:
a. Inefficient use of CPU in single program and maximum use of CPU in multiprogramming. Inefficient use of memory because of external fragmentation. I/O can be used in an efficient way in multiprogramming. b. Batch processing is mainly used for off-line and CPU-bound jobs where
the jobs are put together and are fed the computer system at once.
2) Time-sharing systems
a. A time-sharing system multiplexes the CPU time among different
processes in order to make an illusion that each process has a private CPU.
b. The time-sharing system provides an interactive computing environment; however the involved context-switching has a lot of overhead that causes the whole approach inefficient.
3) Personal computers
a. A personal computer (PC) is designed to serve the sole user of the computer system, hence maximizing the resource utilization is not followed.
b. A PC is used to serve the user and to provide ease of use for the user (usability). The resources including CPU are wasted a lot since they are working idle during the time the system is waiting for the user to invoke a service.
4) Handheld computers
a. A hand held computer system is used to navigate the Internet and also to organize the user’s tasks and meetings.
Question 2 (bootstrap): [5 marks]
Answer True or False to the following statements about the Bootstrap Program in a computer system.
1) Bootstrap program is a part of the kernel of the Unix operating system.
FALSE
2) Bootstrap program is a small program that loads the Kernel of operating system from hard disk to the computer memory.
TRUE
3) Bootstrap program is kept in the dynamic RAM memory of the computer.
FALSE
4) Bootstrap program is the first program that runs after the computer is turned on.
Question 3 (I/O device): [18 marks]
Figure below illustrates the interrupt-driven I/O operation of a computer system to transfer blocks of data from disk drive to (not shown) main memory.
1) Draw three boxes for “Main Memory”, “Direct Memory Access (DMA)” and “I/O Devices” and connect them to this figure to make a complete computer system.
2) Briefly explain the steps shown in the figure to indicate how a block of data will be transferred from disk drive to memory using the interrupt handling operations. In your explanation you should use the terms “interrupt”, “interrupt vector”, and “interrupt routine”. Also you should mention which component is responsible for transferring data.
Answer:
1. By sending special control bytes, the CPU programs the disk controller registers to read a block of data from a particular cylinder and sector of the disk drive; the CPU then continues its operations.
2. After a block of data is read from the disk drive, the disk controller raises its interrupt signal to let the CPU know about that. This signal is transferred to an interrupt controller device which encodes its input signals into binary numbers.
Memory DMAC I/O C
I/O Devices
3) Briefly explain how DMA would be used to transfer data from disk drive to memory; and what is the advantage of this method against the above method in 2).
Extended answer:
DMA transfers a block of data from the buffer within an I/O device controller to a memory locaion or vice versa, without the intervention of CPU. Therefore, the data transfer is much faster than when CPU is transferring data. CPU programs DMA either directly by writing control data into its registers or by letting DMA to read control data from memory locations. Then DMA steals CPU cycles and during the time that CPU is not using buses, DMA isolates CPU from system buses (by activating hold signal) and directly reads data from I/O device controller and writes them into memory buffer. DMA may transfer data by single transfer of bytes or by group transfer of bytes (burst mode).
The advantage of data transfer using DMA is that data is transferred without executing data transfer instructions by the CPU which are very time consuming. Also, the transfer is performed (in parallel) while CPU is performing useful tasks.
Question 4 (CPU mode): [6 marks]
Answer True or False to the following statements about two modes of CPU operation:
user and monitor.
1) CPU changes its mode from user to monitor when an I/O instruction is executed. TRUE
2) In user mode the user’s programs are protected against other users’ programs from being accessed or modified. FALSE
3) Any system call to the operating system causes the CPU to change its mode to monitor. TRUE
Question 5 (process): [14 marks]
With regard to the different states of a process in a computer system during its lifetime answer to the following questions:
1) Name each state of the process; and define each state in only one line.
See page 96 of text book
2) Draw the state transition diagram of a process and label each state and each transition in the diagram. Briefly explain the transitions and the queues in which the process will be waiting.
Transitions:
1. Admitted: a new job is brought into memory that becomes a process; OS creates a PCB and a PID for the newly created process. The new process is put in the ready queue, where the active processes are scheduled by the short-term scheduler with a specific strategy. Process sate is ready.
2. Dispatch: based on the adopted scheduling strategy the short-term scheduler selects the process from the ready-queue (now at the head of queue) and assigns it to the CPU to execute it. Process state is running
3. Interrupt: time quantum of the process in the running state has been expired and
Queue of jobs
Ready queue
5. I/O or event completion: after the requested I/O or the invoked service is completed, the kernel sends a signal to the waiting process to wake up, and the process is sent to the ready queue. Process state is ready.
6. Exit: process completed its operations and terminated. All the resources of the process are returned back to the operating system. Process state is terminated.
Question 6 (context switch): [6 marks]
Answer True or False to the following statements:
1) When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process. TRUE
2) Direct Memory Access (DMA) can be used to reduce the I/O operations during the context switching. FALSE
3) Computer hardware and special purpose CPU instructions can be used to reduce the context switching time. TURE
4) Context switching is a means to switch between the user processes, whereas the operating system processes are always running. FALSE
Question7 (process creation): [6 marks]
Answer True or False to the following statements.
1) A parent process creates a child process by the means of a copy and paste program within the operating system. FALSE
2) The child process is created by copying all the context of the parent process into a new slot of the File Control Block (FCB) table. TRUE
3) The parent and child process will be running concurrently and the parent process is in charge of all the resources the child process is using. TRUE
Question 8 (IPC): [12 marks]
In figure below, briefly explain the steps of operations (using the numbers in figure) that the server and client perform to communicate through sockets:
Answer:
• 1. Server process creates a server-socket. This socket should be advertised for the clients to use it to connect to the server.
• 2. Server process binds the socket to a hardware port of the computer system.
• 3. Server process listens to the socket so that if a new client process arrives, it can catch it. The server socket may have a known port number such as for FTP, rlogin, web server, ..)
• 7. Client process creates a client socket to connect to the server process.
• 8. Client process connects to the server and obtains the port number of server with which it can send and receive messages.
• 4. Server process receives the request-to-connect message from client, gets the IP&Port addresses of the client and establishes a socket connection with the client. (The server assigns a child process to serve the client).
• 9, 5, 6, 10. Client process sends message to the server and receives its response.
1
2
3
4
5
6
7
8
9
Question 9 (file system): [16 marks]
1) Name five attributes of a file that are stored by the file system
Name, identifier, type, location, size, protection, time, date, user identification (page 372 text book)
2) Briefly explain how the following operating systems mount a new file system in the computer system to be accessed by the users.
a) Unix
Uses explicit command “mount()” to mount a file system. A file system is mounted at an empty directory location in a hierarchy of directory structure whose root is “/”.
b) Macintosh
When a new disk is connected to the system, Macintosh searches for a file system on the device. If it finds one, it automatically mounts the file system on the device
c) Windows
Windows has two-level directory structure, with devices and partitions assigned a drive letter, Partitions have a general graph directory structure associated with the drive letter, e.g., C:\cs3sh3\assign1\
Question 10 (file system): [5 marks]
Mike, the manager, has the right to read and change any files in his company. Tom is one of the team leaders in the company. He has the right to control all files in the team and read other teams’ file only. Tom has three assistants Jim, David and John. Each of them is working on a project. The assistants can read and execute others’ work in the team, but they cannot write in it or access the files of other teams. Now, you are the
system-administrator of the company. Set the access permission for them in UNIX.
Access permission bits:
Owner Group Public RWX RWX RWX
1) Mike 1 1 1 1 1 1 1 1 1
2) Tom 1 1 1 1 1 1 1 0 0
3) Jim 1 1 1 1 0 1 0 0 0
4) David 1 1 1 1 0 1 0 0 0