Introduction Lab
Transcript of Introduction Lab
-
8/6/2019 Introduction Lab
1/23
Operating Systems
1 IntroductionLab notes
Course lectured by Prof. Gabriel Kuper
Lab assist. Ilya Zaihrayeu
http://www.dit.unitn.it/~ilya/os.htm
-
8/6/2019 Introduction Lab
2/23
Ilya Zaihrayeu Operating Systems Course 2
Operating System
Operating System: a program that acts asan intermediary between a user of a
computer and the computer hardwareQ: What are the two main functions of an
operating system?
A: Make user work with
the hardware convenient
Efficientoperation ofthe computer system
-
8/6/2019 Introduction Lab
3/23
Ilya Zaihrayeu Operating Systems Course 3
Operating System, contd
Q: What are the five basic services provided by anoperating 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. Forefficiency and protection, users usually cannotcontrol I/O devices directly. Therefore, the operatingsystem must provide some means to do I/O
File-system manipulation: programs need to readand writes files. They also need to create and deletefiles by name
-
8/6/2019 Introduction Lab
4/23
Ilya Zaihrayeu Operating Systems Course 4
Operating System, contd
A [contd]:
Communication: there are many circumstances in
which one process needs to exchange informationwith another process. Communications may beimplemented via share memory, or by the techniqueof 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 mayoccur in the CPU and memory hardware, in I/O
devices, or in a program. For each type of error, theoperating system should take the appropriate actionto ensure correct and consistent computing
-
8/6/2019 Introduction Lab
5/23
Ilya Zaihrayeu Operating Systems Course 5
Operating System, contd
A possible point from which it is convinient to viewan 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
-
8/6/2019 Introduction Lab
6/23
Ilya Zaihrayeu Operating Systems Course 6
Process Management
Q: What are the five major activities of an operating systemin regard to process management?
Aprocess is a program in execution. A process needscertain resources, including CPU time, memory, files, andI/O devices, to accomplish its task
A:
Creation and deletion of both user and systemprocesses
Suspension and resumption of processes
Provision of mechanisms for process synchronization
Provision of mechanisms for process communication Provision of mechanisms for deadlock handling
-
8/6/2019 Introduction Lab
7/23
Ilya Zaihrayeu Operating Systems Course 7
Main-memory Management
Q: What are the three major activities of an operatingsystem in regard to main-memory management?
Memory is a large array of words or bytes, each with its ownaddress. It is a repository of quickly accessible data shared by theCPU and I/O devices. Main memory is a volatile storage device. Itloses 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 becomesavailable
Allocate and deallocate memory space as needed
-
8/6/2019 Introduction Lab
8/23
Ilya Zaihrayeu Operating Systems Course 8
File Management
Q: What are the five major activities of an operating systemin regard to file management?
A file is a collection of related information defined by itscreator. Commonly, files represent programs (both sourceand 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
-
8/6/2019 Introduction Lab
9/23
Ilya Zaihrayeu Operating Systems Course 9
Secondary-storage Management
Q: What are the three major activities of an operatingsystem in regard to secondary-storage management?
Since main memory (primary storage) is volatile and too smallto accommodate all data and programs permanently, thecomputer system must provide secondary storage to back upmain memory. Most modern computer systems use disks as
the principle on-line storage medium, for both programs anddata
A: Free space management Storage allocation
Disk scheduling
-
8/6/2019 Introduction Lab
10/23
Ilya Zaihrayeu Operating Systems Course 10
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, mainframesare just below supercomputers
-
8/6/2019 Introduction Lab
11/23
Ilya Zaihrayeu Operating Systems Course 11
Personal Computers vs. Mainframes,
contdA:
Personal computers only allow one user at a time. There isno need for OS to handle with process scheduling andpermission. No timesharing. For example, in DOS, theuser can have as many processes as he wants but thework must be done one job at a time. If a parent processproduces a child, the parent is suspended until its child
finishes its job. No parallelism achieved
Mainframes, on the other hand, allow timesharing andmany users can log on at the same time. The OS must be
able to check process's owners and permission, etc tokeep everything in order. Parallelism can be achievedthrough process switching. The parents and the childrencan work together simultaneously
-
8/6/2019 Introduction Lab
12/23
Ilya Zaihrayeu Operating Systems Course 12
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 oflayers (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 selectedsuch that each uses functions
(operations) and services of
only lower-level layers
-
8/6/2019 Introduction Lab
13/23
Ilya Zaihrayeu Operating Systems Course 13
Layered System Design, contd
A: Advantage: modularity. This simplifies debugging
and system verification. The layers are selectedsuch that each uses functions and services of onlylower-level layers. The first layer can be debuggedwithout any concern for the rest of the system,because it uses only the basic hardware (which isassumed to be correct) to implement its functions.Once the first layer is debugged, its correctfunctioning can be assumed while the second layeris worked on, and so on. If an error is found duringthe debugging of a particular layer, we know thatthe error must be on that layer, because the layersbellow it are already debugged
-
8/6/2019 Introduction Lab
14/23
Ilya Zaihrayeu Operating Systems Course 14
Layered System Design, contd
A [contd]:
Disadvantage: system calls take longer since
parameters and data may be modified and/or passedat 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 CPUscheduling layer, and finally to the hardware. Thus
each layer adds overheadto the system call and the
net result is a system call that takes longer then one
does on a non-layered system
-
8/6/2019 Introduction Lab
15/23
Ilya Zaihrayeu Operating Systems Course 15
DMA and Multiprogramming
Q: On early computers, every byte of data read orwritten was directly handled by the CPU (i.e. therewas no DMA). What implications does this
organization have for multiprogramming?
Direct Memory Access (DMA) is a technique for transferring datafrom main memory to a device without passing it through theCPU. Computers that have DMA channels can transfer data toand from devices much more quickly than computers without aDMA channel can
Multiprogramming is a rudimentary form of parallel processing inwhich several programs are run at the same time on auniprocessor. Since there is only one processor, there can be no
true simultaneous execution of different programs. Instead, theoperating system executes part of one program, then part ofanother, and so on. To the user it appears that all programs areexecuting at the same time
-
8/6/2019 Introduction Lab
16/23
Ilya Zaihrayeu Operating Systems Course 16
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 CPUutilisation) by multi-programming. No matter
how much I/O a program does, the CPU will
be 100 percent busy
-
8/6/2019 Introduction Lab
17/23
Ilya Zaihrayeu Operating Systems Course 17
The Shell and the Kernel
Q: What is the purpose of the commandinterpreter? Why is it usually separate from thekernel?
A command interpreteris the part of a computer operatingsystem that understands and executes commands that areentered interactively by a human or from a program. Insome operating systems, the command interpreter iscalled the shell
Kernelis the central module of an operating system. It isthe part of the operating system that loads first, and itremains in main memory. Because it stays in memory, it isimportant for the kernel to be as small as possible while
still providing all the essential services required by otherparts of the operating system and applications. Typically,the kernel is responsible for memory management,process and task management, and disk management
-
8/6/2019 Introduction Lab
18/23
Ilya Zaihrayeu Operating Systems Course 18
The Shell and the Kernel, contd
A: The command interpreter is
usually separate from the
kernel because its purposediffers from that of the kernel.The kernel's job is to allowmultiple programs, multiple
users in multi-user systems toaccess the hardware as if eachprogram had its own computer
Another advantage to separating the kernel from thecommand interpreter is that it allows different
command interpreters to be run without kernelmodification. Since the kernel does not include thecommand interpreter, the user can choose whichshell he or she will use
-
8/6/2019 Introduction Lab
19/23
Ilya Zaihrayeu Operating Systems Course 19
Traps and Interrupts
Q: What is the main difference between a trap andinterrupt?
An interruptis a a signal informing a program that an eventhas occurred. When a program receives an interruptsignal, it takes a specified action (which can be to ignorethe signal). Interrupt signals can cause a program tosuspend 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 softwareinterrupts. A software interrupt is also called a trap or anexception. Traps are usually caused either by an error (forexample division by zero or invalid memory access), or bya specific request from a user program that an operating-system service be performed
-
8/6/2019 Introduction Lab
20/23
Ilya Zaihrayeu Operating Systems Course 20
Traps and Interrupts, contd
A: A trap and an interrupt differ with respect to the
sources that generate them. A trap is a software-generated and may be caused either by an error ora user request while an interrupt is a hardware-generated change-of-flow within the system
An interrupt handler is activated to deal with thecause of the interrupt; control is then returned to theinterrupted context and instruction
An interrupt can be used to signal the completion of
an I/O to obviate the need for device polling while atrap can be used to call operating system routinesor to catch arithmetic errors
-
8/6/2019 Introduction Lab
21/23
Ilya Zaihrayeu Operating Systems Course 21
Kernel Mode
Q: Which of the following instructions should be allowed only inkernel mode?a) Disable all interrupts
b) Read the time-of-day clockc) 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 interruptsand never re-enables it. No other processes, not even OS itself,can work since there will be no clock interrupt to allow OS toswitch from one process to another
b) No. It is not critical enough
c) Yes. Clock is very important and should be allowed to changeby only kernel
d) Yes. Memory mapping should be reserved only for the kernel
-
8/6/2019 Introduction Lab
22/23
-
8/6/2019 Introduction Lab
23/23
Ilya ZaihrayeuOperating Systems Course 23
References
Andrew S. Tanenbaum, Modern Operating
Systems
Silberschatz Galvin, Operating System
Concepts