You are on page 1of 23

Operating Systems

1 Introduction
Lab notes
Course lectured by Prof. Gabriel Kuper Lab assist. Ilya Zaihrayeu http://www.dit.unitn.it/~ilya/os.htm

Operating System Operating System: a program that acts as an intermediary between a user of a computer and the computer hardware Q: What are the two main functions of an operating system? A:
Make user work with the hardware convenient Efficient operation of the computer system
Ilya Zaihrayeu Operating Systems Course

Operating System, contd


Q: What are the five basic services provided by an operating system? A:
Program execution: the system must be able to load a program into memory and run it I/O operations: a running program may require I/O. This I/O may involve a file or an I/O device. For efficiency and protection, users usually cannot control I/O devices directly. Therefore, the operating system must provide some means to do I/O File-system manipulation: programs need to read and writes files. They also need to create and delete files by name
Ilya Zaihrayeu Operating Systems Course

Operating System, contd


A [contd]:
Communication: there are many circumstances in which one process needs to exchange information with another process. Communications may be implemented via share memory, or by the technique of message passing, in which packets of information are moved between processes by operating system Error detection: the operating system constantly needs to be aware of possible errors. Errors may occur in the CPU and memory hardware, in I/O devices, or in a program. For each type of error, the operating system should take the appropriate action to ensure correct and consistent computing
Ilya Zaihrayeu Operating Systems Course

Operating System, contd


A possible point from which it is convinient to view an operating system: a set of disassembled system components and their interconnections System components are:
Process management Main-memory management File management I/O system management Secondary-storage management Networking Protection system Command-interpreter system
Ilya Zaihrayeu Operating Systems Course

Process Management
Q: What are the five major activities of an operating system in regard to process management?
A process is a program in execution. A process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task

A:
Creation and deletion of both user and system processes Suspension and resumption of processes Provision of mechanisms for process synchronization Provision of mechanisms for process communication Provision of mechanisms for deadlock handling

Ilya Zaihrayeu

Operating Systems Course

Main-memory Management
Q: What are the three major activities of an operating system in regard to main-memory management?
Memory is a large array of words or bytes, each with its own address. It is a repository of quickly accessible data shared by the CPU and I/O devices. Main memory is a volatile storage device. It loses its contents in the case of system failure

A:
Keep track of which parts of memory are currently being used and by whom Decide which processes to load when memory space becomes available Allocate and deallocate memory space as needed
Ilya Zaihrayeu Operating Systems Course

File Management
Q: What are the five major activities of an operating system in regard to file management?
A file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data

A:
File creation and deletion Directory creation and deletion Support of primitives for manipulating files and directories Mapping files onto secondary storage File backup on stable (nonvolatile) storage media
Ilya Zaihrayeu Operating Systems Course

Secondary-storage Management
Q: What are the three major activities of an operating system in regard to secondary-storage management?
Since main memory (primary storage) is volatile and too small to accommodate all data and programs permanently, the computer system must provide secondary storage to back up main memory. Most modern computer systems use disks as the principle on-line storage medium, for both programs and data

A:
Free space management Storage allocation Disk scheduling
Ilya Zaihrayeu Operating Systems Course

Personal Computers vs. Mainframes Q: List some differences between personal computer operating systems and mainframe operating systems
Mainframe is a very large and expensive computer capable of supporting hundreds, or even thousands, of users simultaneously. In the hierarchy that starts with a simple microprocessor (in watches, for example) at the bottom and moves to supercomputers at the top, mainframes are just below supercomputers
Ilya Zaihrayeu Operating Systems Course

10

Personal Computers vs. Mainframes, contd


A:
Personal computers only allow one user at a time. There is no need for OS to handle with process scheduling and permission. No timesharing. For example, in DOS, the user can have as many processes as he wants but the work must be done one job at a time. If a parent process produces a child, the parent is suspended until its child finishes its job. No parallelism achieved Mainframes, on the other hand, allow timesharing and many users can log on at the same time. The OS must be able to check process's owners and permission, etc to keep everything in order. Parallelism can be achieved through process switching. The parents and the children can work together simultaneously
Ilya Zaihrayeu Operating Systems Course

11

Layered System Design Q: What is the main advantage and disadvantage of the layered approach to system design?
In the levered approach the operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface. With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers
Ilya Zaihrayeu Operating Systems Course

12

Layered System Design, contd


A:
Advantage: modularity. This simplifies debugging and system verification. The layers are selected such that each uses functions and services of only lower-level layers. The first layer can be debugged without any concern for the rest of the system, because it uses only the basic hardware (which is assumed to be correct) to implement its functions. Once the first layer is debugged, its correct functioning can be assumed while the second layer is worked on, and so on. If an error is found during the debugging of a particular layer, we know that the error must be on that layer, because the layers bellow it are already debugged
Ilya Zaihrayeu Operating Systems Course

13

Layered System Design, contd


A [contd]:
Disadvantage: system calls take longer since parameters and data may be modified and/or passed at each layer. For instance, for a user program to execute an I/O operation, it executes a system call which is trapped to the I/O layer, which calls the memory management layer, through to the CPU scheduling layer, and finally to the hardware. Thus each layer adds overhead to the system call and the net result is a system call that takes longer then one does on a non-layered system

Ilya Zaihrayeu

Operating Systems Course

14

DMA and Multiprogramming


Q: On early computers, every byte of data read or
written was directly handled by the CPU (i.e. there was no DMA). What implications does this organization have for multiprogramming?
Direct Memory Access (DMA) is a technique for transferring data from main memory to a device without passing it through the CPU. Computers that have DMA channels can transfer data to and from devices much more quickly than computers without a DMA channel can Multiprogramming is a rudimentary form of parallel processing in which several programs are run at the same time on a uniprocessor. Since there is only one processor, there can be no true simultaneous execution of different programs. Instead, the operating system executes part of one program, then part of another, and so on. To the user it appears that all programs are executing at the same time
Ilya Zaihrayeu Operating Systems Course

15

DMA and Multiprogramming, contd

A:
The prime reason for multi-programming is to give the CPU something to do while waiting for I/O to complete. If there is no DMA, the CPU is fully occupied doing I/O, so there is nothing to be gained (at least in terms of CPU utilisation) by multi-programming. No matter how much I/O a program does, the CPU will be 100 percent busy

Ilya Zaihrayeu

Operating Systems Course

16

The Shell and the Kernel


Q: What is the purpose of the command interpreter? Why is it usually separate from the kernel?
A command interpreter is the part of a computer operating system that understands and executes commands that are entered interactively by a human or from a program. In some operating systems, the command interpreter is called the shell Kernel is the central module of an operating system. It is the part of the operating system that loads first, and it remains in main memory. Because it stays in memory, it is important for the kernel to be as small as possible while still providing all the essential services required by other parts of the operating system and applications. Typically, the kernel is responsible for memory management, process and task management, and disk management
Ilya Zaihrayeu Operating Systems Course

17

The Shell and the Kernel, contd


A:
The command interpreter is usually separate from the kernel because its purpose differs from that of the kernel. The kernel's job is to allow multiple programs, multiple users in multi-user systems to access the hardware as if each program had its own computer Another advantage to separating the kernel from the command interpreter is that it allows different command interpreters to be run without kernel modification. Since the kernel does not include the command interpreter, the user can choose which shell he or she will use
Ilya Zaihrayeu Operating Systems Course

18

Traps and Interrupts


Q: What is the main difference between a trap and interrupt?
An interrupt is a a signal informing a program that an event has occurred. When a program receives an interrupt signal, it takes a specified action (which can be to ignore the signal). Interrupt signals can cause a program to suspend itself temporarily to service the interrupt. Interrupts can be generated by devices, such as a printer or keyboard, to indicate that some event has occurred. These are called hardware interrupts Interrupt signals initiated by programs are called software interrupts. A software interrupt is also called a trap or an exception. Traps are usually caused either by an error (for example division by zero or invalid memory access), or by a specific request from a user program that an operatingsystem service be performed
Ilya Zaihrayeu Operating Systems Course

19

Traps and Interrupts, contd


A:
A trap and an interrupt differ with respect to the sources that generate them. A trap is a softwaregenerated and may be caused either by an error or a user request while an interrupt is a hardwaregenerated change-of-flow within the system An interrupt handler is activated to deal with the cause of the interrupt; control is then returned to the interrupted context and instruction An interrupt can be used to signal the completion of an I/O to obviate the need for device polling while a trap can be used to call operating system routines or to catch arithmetic errors
Ilya Zaihrayeu Operating Systems Course

20

Kernel Mode
Q: Which of the following instructions should be allowed only in
kernel mode? a) Disable all interrupts b) Read the time-of-day clock c) Set the time-of-day clock d) Change the memory map
a)

A:
Yes. If CPU allows user processes to disable all interrupts, chaos will occur. Say one user process disables all interrupts and never re-enables it. No other processes, not even OS itself, can work since there will be no clock interrupt to allow OS to switch from one process to another No. It is not critical enough Yes. Clock is very important and should be allowed to change by only kernel Yes. Memory mapping should be reserved only for the kernel
Ilya Zaihrayeu Operating Systems Course

b) c) d)

21

Client-server Model
Q: The client-server model is popular in distributed systems. Can it also be used in a single-computer system? If it can, then how? Client/server describes the relationship between two computer programs in which one program, the client, makes a service request from another program, the server, which fulfills the request. In a network, the client/server model provides a convenient way to interconnect programs that are distributed efficiently across different locations A: Yes. All that is required is a multiprogramming system; allow one process to be the server and another to be the client
Ilya Zaihrayeu Operating Systems Course

22

References Andrew S. Tanenbaum, Modern Operating Systems Silberschatz Galvin, Operating System Concepts

Ilya Zaihrayeu

Operating Systems Course

23

You might also like