Operating Systems Operating Systems: Learning Outcomes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Operating Systems

Aims
To introduce the concept of Operating Systems. To demonstrate that there are multiple Operating Systems. To briefly discuss the structure of Operating Systems.

Operating Systems
Learning outcomes
For the student to be aware of the hardware/software interface. For the student to be aware of the fundamental purposes and functions of an operating system. For the student to be aware of some different operating systems structures.

Operating Systems
Reading
http://homepages.feis.herts.ac.uk/unit9/index.html. Understanding Computers Today and Tomorrow 2002 edition, Chapter 6 Software pages 209 250. Interactive Exercise SW 250. Some of this material is based on Operating System Concepts (6th Ed.) Silbershatz, Galvin and Gagne.
3

Operating Systems
The most fundamental of all the system programs is the operating system. An operating system controls all of a computers resources. An operating provides the base upon which application and user programs can be written.
4

Operating Systems
An operating system is a program that:
manages computer hardware. provides a basis for application programs. serves as an intermediary between a computer user and its hardware.
5

Operating Systems
The main purposes of an operating system are to:
permit a user to conveniently and efficiently execute application programs on computer hardware . fairly and efficiently allocate computer resources. serve as a control program that:
prevents errors and improper use of the computer. manages the operation and control of I/O.
6

Operating Systems
The hardware/software interface
A virtual machine
Games Word Processor Data bases

Operating Systems
An operating system must be protected.

application programs
interpreter

There are two modes of operation:


User Mode. Kernel Mode or Supervisor Mode.

Compilers

Editor

Command (shell)

system programs
Operating system Machine language

Microprogramming

hardware

A mode bit (in hardware) identifies the current mode:


0 for Kernel Mode. 1 for User Mode.
7 8

Physical devices

Operating Systems
An operating system is protected from its computer users. An operating system protects multiple computer users from one another. This is achieved by use of privileged instructions.
9

Operating Systems
Hardware only permits privileged instructions to be executed in Kernel Mode. If User Mode attempts to execute a privileged instruction, then hardware traps it to the operating system.

10

Operating Systems
A trap is a software generated interrupt. An interrupt is a hardware generated change of flow within a computer system. Operating systems are usually interrupt driven.
11

Operating Systems
A trap or exception is a software generated interrupt that notifies the operating system that a service should be performed. An interrupt is a hardware generated change of flow within a computer system.

12

Operating Systems
Operating systems are usually interrupt driven. Hardware triggers an interrupt by sending a signal to the CPU (usually via the system bus). Software triggers an interrupt by executing a system call.
13

Operating Systems
A system call creates, deletes and uses the software objects that are managed by the operating system. The most important objects are:
processes. files.

14

Operating Systems
Processes are a key concept of an operating system. A process is a program that is undergoing execution.

Operating Systems
A process consists of:
an executable program. the programs data. the programs stack. the programs PC. the programs registers in the CPU. and any other resource required to run the program.
16

15

Operating Systems
A process requires:
CPU time. memory allocation. files. I/O devices.

Operating Systems
Processes undergo state changes. As a process executes its state changes:
New state: a process that is being created. Running state: program instructions undergoing execution. Waiting state: a process waiting for an event to occur. Ready state: a process waiting execution. Terminated state: a process that has completed execution.
17 18

A process consists of:


an executable program. the programs data.

Operating Systems

Operating Systems
A computer system, therefore, consists of multiple processes. A process as described so far, performs a single thread of execution. It is desirable to have multiple threads of execution to maximise CPU utilisation.
19 20

Figure 4.1 Process States (Operating System Concepts Silbershatz, Galvin and Gagne Ed 6.)

Operating Systems
However, a uniprocessor can only run one process at any one time. Other processes must therefore wait
until the CPU is available or until the CPU is rescheduled.

Operating Systems
Newly created processes are put into a job queue (a job is an alternative name for a process). Processes that are stored in Main Memory and are in the ready state are kept in a linked list (see Computation Notes) called the ready queue.
21 22

Operating Systems
A process that is selected for execution is scheduled by a dispatcher and dispatched to the CPU for execution. Such a process will run for a while and:
will quit and be terminated if it runs to completion. will be returned to the ready queue if it is interrupted. will be sent to the waiting queue if it is waiting for the completion of an event such as I/O.

Operating Systems
Context Switching is the procedure of switching one process to another in the CPU. Context switching is done in Kernel Mode. The state of the old process must be saved so that when it returns to running state it can continue from the point it was switched. The state of the new process must then be loaded into the CPU registers etc.
23 24

Operating Systems
During a context switch no useful work is done, therefore, context switch time is pure overhead. Typical context switch times vary between 1 microsecond and 1 second depending on memory speed, the number of register changes etc.
25

Operating Systems
Process Creation:
Processes have identity.
Each PID (Process Identifier) is unique.

A process is created by a fork system call. A parent process can create child processes. A child process can then become a parent process by spawning its own child processes. The result is a tree like structure.
26

Operating Systems
A

Operating Systems
A child process may be able to:
obtain its resources from the operating system. or be provided with a subset of the parent resources.

A Process Tree

A parent process can partition its resources between its child processes, resulting in shared resources such as files or memory.
27 28

Operating Systems
When a parent creates child processes:
the parent can execute concurrently with its child processes. the parent can wait until some (or all) of its child processes are terminated.

Operating Systems
Process Termination (1)
A process terminates when it completes execution.
A process requests to be terminated by the operating system by an exit system call. An exit system call may return output from the child process to the parent process (by a waiting system call). An exit system call will deallocate all resources from the terminated process.
30

29

Operating Systems
Process Termination (2)
A process terminates when it is terminated by another process.
A process requests the termination of a different process by an abort system call. It is usually a parent process that is undergoing termination that requests an abort system call for its child processes. A parent process must therefore know the identities of its child processes.
31

Operating Systems
Process Termination (2)
A parent process may terminate a child process:
When the child process has exceeded its resource usage. The parent process requires mechanisms to inspect its child process states. The task that the child process was assigned is no longer necessary. The parent process is undergoing termination. The operating system does not permit the existence of child processes without their parent process. This is called cascading termination.
32

Operating Systems
Concurrent processes can either execute independently of other processes or by cooperating with other processes. Cooperating processes provide:
information sharing. computation speedup. convenience.
33

Operating Systems
Cooperating processes:
communicate in a shared memory environment. share a common buffer pool that is written by the application programmer. share an address space.

34

Operating Systems
Interprocess Communication (IPC):
provides a means of communication without a shared environment. IPC is particularly useful in distributed systems. IPC is provided by a message-passage system. IPC requires processes to synchronise their actions.

Operating Systems
Files are a key concept of an operating system. The file system is the most visible aspect a computer user has of an operating system. Files provide mechanisms for:
35

storage of data and programs. access to data and programs.

36

Operating Systems
A file system consists of:
a collection of files, where each file stores data. a directory structure that organises and provides information about the files. A file:

Operating Systems
is named by its computer user and is subsequently referenced by that name. has a unique identifier, which is the non-human readable name for that file. has type, which is the information needed by the computer system that describes the file. has a location. has size. has protection. has a time, a date and a user identification.
38

37

Operating Systems
A file structure:
From an operating system viewpoint a file is an unstructured sequence of bytes. File meaning is by an application program. User programs can therefore put anything into a file without consideration of the operating system.

Operating Systems
A directory structure:
is a means of locating files together under the control of a computer user. is hierarchical - usually a (deep) tree structure. the top directory in the hierarchy is called the root directory. every file with a directory can be specified by providing its path name from the root directory (the absolute path name).

39

40

Operating Systems
Before a file can be opened for reading or writing its permissions must be checked. If file access is permitted a file descriptor (or file handler) is returned. If file access is not permitted an error code is returned.
41

Operating Systems
Many operating system provide computer users the capability to perform I/O operations without the need of knowing the underlying hardware complexities. In this case each I/O device is represented by a special file. Special files have the effect of making I/O devices appear as files. I/O devices can therefore be read from or written to by use of special files.
42

Operating Systems
Block special files are abstract representations of addressable blocks, such as disks. Character special files are abstract representations of character streams, such as line printers and network interfaces.

Operating Systems
Operating system structure:
Simple Structure, such as MS-DOS. Layered Structure, such as UNIX. Microkernel Structure, such as WindowsNT clientserver structure. Virtual Machine Structure, such as Java Virtual Machine (JVM).

43

44

Operating Systems
Simple Structure, such as MS-DOS
Many commercial systems do not have a well defined operating system structure. Originally they tended to be small, simple and limited operating systems. But they grew beyond a simple structure into a Monolithic Structure (MS-DOS).

Operating Systems

45

Simple Structure, such as MS-DOS (Figure 3.6 Operating 46 Concepts Ed 6 Silberschatz, Galvin and Gagne.)

Operating Systems
Layered Operating System Structure
A main program that invokes the requested service procedure. A set of service procedures that carry out system calls.

Operating Systems
main procedure

service procedures

utility procedures

A simple layered structure

A set of utility procedures that help the service procedures.


47 48

Operating Systems
Layered Operating System Structure, such as UNIX. The operating system is divided into a series of layers. The bottom layer (0) is the hardware. The top layer (N) is the user application interface.

Operating Systems

49

Layered Operating System Structure, such as UNIX (Figure 3.7 Operating Concepts Ed 6 Silberschatz, Galvin 50 and Gagne.)

Operating Systems
Some other Layered Operating System Structures:
Technische Hogeschool Eindhoven (THE) project students in Holland. MULTICS concentric rings (layer 0 being the most protect inner ring, layer N being the least protected outer ring).

Operating Systems
Microkernel Operating System Structures, such as MACH and WindowsNT
a Microkernel approach modularises the kernel. a Microkernel approach removes all nonessential components from the system-level Kernel Mode and puts them with in the user-level programs. the result is a smaller Kernel Mode. a Microkernel typically provides minimal process and memory management. a Microkernel typically provides a communication facility between a client program and the services running in user space. Communication is by message-passing, such as Interprocess Communication (IPC).
52

51

Operating Systems
POSIX server

Operating Systems
Virtual Machine Structure, such as Java Virtual Machine (JVM). Is a specification for an abstract computer. Takes the layered approach to its logical conclusion. Treats hardware and the operating system kernel as though they were all hardware. Provides an interface identical to the underlying bare hardware. Creates the illusion of multiple processes, with each process apparently executing on its own processor with its own (virtual) memory. 54

A Microkernel Operating Structure (Figure 3.10 Operating Concepts Ed 6 Silberschatz, Galvin and Gagne.)
53

Operating Systems

Translators and Interpreters


Machine translation Source language
Program in source language Compiler

Target/Object language
Program in target language

Errors and diagnostics

A comparison of a non-virtual machine and a virtual machine (Figure 3.11 Operating Concepts Ed 6 Silberschatz, Galvin and Gagne.) 55

56

Translators and Interpreters


Machine Interpreter Combined translator and interpreter

57

10

You might also like