+ All Categories
Home > Documents > Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS...

Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS...

Date post: 05-Jun-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
45
Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : [email protected] Reference Operating System Concepts, ABRAHAM SILBERSCHATZ Operating Systems
Transcript
Page 1: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Designed and Presented by

Dr. Ayman Elshenawy Elsefy

Dept. of Systems & Computer Eng..

AL-AZHAR University

Website : eaymanelshenawy.wordpress.com

Email : [email protected]

Reference

Operating System Concepts, ABRAHAM SILBERSCHATZ

Operating Systems

Page 2: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Chapter 2: Operating-System Structures

Page 3: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Chapter 2: Operating-System Structures

•OS Services provided

•User OS Interface

•System Calls

•Types of System Calls

•System Programs

•OS Design and Implementation

•OS Structure

•Virtual Machines

•OS Debugging and Generation

•System Boot

Page 4: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Services

Operating system can be viewed from many points: What are the services that the system provides, and how?

What are types of interface that it makes available to users andprogrammers;

Its components and their interconnections.

How operating systems is created and how a computer starts it?

Operating system provides: An environment for the execution of programs ( provide services

to programs to make the programming task easier and to the usersof those programs )

OS services differ from one to another, but we can identifycommon classes

Operating system services are:

Functions that are helpful to the user

Functions for ensuring efficient operation of the system.

Page 5: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Services

Page 6: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Services that Helps the user

•User interface (UI): can take several forms Command-Line (CLI): use a text commands and method for entering.

Batches: execute file contains a set of commands.

Graphics User Interface (GUI): windows, menus, mouse cursorsand icons.

•Program execution load a program into memory, run that program, end it (success /fail)

• I/O operations –A running program may require I/O (file or I/O device), user cant

control I/O (recording to a CD or DVD drive or blanking adisplay screen).

•File-system manipulation:How programs are used to create file, write, read, extend, delete

files and directories, search them, list file Information, permissionand properties of these files.

Page 7: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Services that Helps the user

•Communications: Process needs to exchange information with another process (on

the same computer or in different computers in a network).

May be implemented via shared memory or message passing.

•Error detection. Detect possible errors and take the appropriate action to

ensure correct computing :

in CPU or memory or power failure.

I/O devices (a connection failure on a network, or lack of paperin the printer).

User program errors (arithmetic overflow, attempt to access anillegal memory location, or a too-great use of CPU time).

Debugging facilities can greatly enhance the user’s andprogrammer’s abilities to use the system efficiently.

Page 8: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Services that Helps the System

•Resource allocation multiple users or multiple jobs running at the same time, use shared

resources (such as CPU cycles ( CPU scheduling ), main memory(Memory Management), file storage (file systems) , I/O devices).

•Accounting keep track of which users use how much and what kinds of

computer resources: Users can be billed

Accumulating usage statistics used to reconfigure the system toimprove computing services.

•Protection and security: When several separate processes execute concurrently, it should not

be possible for one process to interfere with the others or with theOS itself.

Protection involves ensuring that all access to system resources iscontrolled.

Security of the system from outsiders is also important (userauthentication, user name and password).

Page 9: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS User Interface – Command Line Interpreter (CLI)

• OS may include CLI :• In the kernel(DOS).• External program (windows and Unix) which run upon request.• Some OS have multiple CLI to choose from are called shells ( In

Unix and Linux Bourne, C shell, Bourne-Again shell, Korn shell.

• Most CLI manipulate files: create, delete, list, print, copy, execute, ..

• These commands can be implemented in two general ways:

• The CLI itself contains the code to execute the command, The size of theCLI depends on the number of commands that can be given (eachcommand have its code)

• implements most commands through system programs, (programmerscan add new commands to the system easily by creating new files withthe proper names.) in this case the command interpreter does notunderstand the command, it merely uses the command to identify a file tobe loaded into memory and executed. Thus, the UNIX command todelete a file (rm is added as a system program)

• rm file.txt

Page 10: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Bourne Shell Command Interpreter

Page 11: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Interface – Graphical User Interface (GUI)•User-friendly desktop interface

• Characterized by a desktop.• The user moves the mouse to position its pointer on images, or icons, on the

desktop.• Icons represent programs, files, directories, and system functions.• Clicking a button on the mouse can invoke a program, select a file or folder or pull

down a menu that contains commands.

•Many systems now include both CLI and GUI interfaces• Microsoft Windows is GUI with CLI “command” shell• Apple Mac OS X as “Aqua” GUI interface with UNIX kernel available• Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)

Page 12: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

The Mac OS X GUI

Page 13: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Interface – Choice of Interface• Is mostly one of personal preference.

•Most Windows users are happy to use the Windows GUIenvironment and almost never use the MS-DOS CLI.

•System administrators who manage computers and powerusers who have deep knowledge of a system frequently usethe CLI interface.•Only a subset of system functions is available via the GUI.,•CLI usually make repetitive tasks easier.• For example, if a frequent task requires a set of command-line

steps, those steps can be recorded into a file, and that file can berun just like a program. The program is not compiled intoexecutable code but rather is interpreted by the CLI. These shellscripts are very common on systems that are command-lineoriented, such as UNIX and Linux.

•The design of a useful and friendly user interface is thereforenot a direct function of the operating system (but providingan adequate service to user programs).

Page 14: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

System Calls

• Programming interface to the services provided by the OS

• Typically written in a high-level language (C or C++)

• Example: writing a simple program to read data from one file and copythem to another file.

• Running a sequence of system calls,

1. First to write a prompting message on the screen

2. Read from the keyboard the characters that define the twofiles (may be selected by mouse).

3. Open the input file (check error – not exist or protected) ifError print message and terminate.

4. If the input file exists, then create a new output file (checkerror– file exist, no memory). Abort if error exist, may deletethe existing file and create a new one.

5. loop that reads from the input file (a system call) and writesto the output file (another system call).

6. close both files (another system call)

7. write a message to the console and terminate normally.

Page 15: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Example of System Calls• System call sequence to copy the contents of one file to another file

Page 16: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

System Calls

•Systems execute thousands of system calls per second andmost programmers never see this level of detail.

•Application developers design programs according to anapplication programming interface (API).

•The API specifies a set of functions that are available to anapplication programmer, including the parameters that arepassed to each function and the return values theprogrammer can expect.

•Three of the most common APIs available to applicationprogrammers:• Win32 API for Windows,

• POSIX API for POSIX-based systems (which include virtually allversions of UNIX, Linux, and Mac OS X),

• Java API for designing programs that run on the Java virtualmachine.

Page 17: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep
Page 18: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Example of Standard API•Consider the Readfield() function in the Win32 APIa function

for reading from a file

• A description of the parameters passed to ReadFile()

• HANDLE file—the file to be read

• LPVOID buffer—a buffer where the data will be read into and written from

• DWORD bytesToRead—the number of bytes to be read into the buffer

• LPDWORD bytesRead—the number of bytes read during the last read

• LPOVERLAPPED ovl—indicates if overlapped I/O is being used

Page 19: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

System Call Implementation

•The run-time support system:A set of functions built into libraries included with a compiler.

A programming languages provides a system-call interfacethat links to system calls made available by the OS.

The system-call interface intercepts function calls in the APIand invokes the necessary system calls within the OS.

A number is associated with each system call, and the systemcall interface maintains a table indexed according to thesenumbers.

The caller need know nothing about how the system call isimplemented or what it does during execution.

It needs only to obey the API standard.

Thus, most of the details of the operating-system interface arehidden from the programmer by the API and are managed bythe run-time support library.

Page 20: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

API – System Call – OS Relationship

Standard C Library Example C program invoking printf() library call, which calls write() system call

The relationship among an API, the

system-call interface, and the OS.

Page 21: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

System Call Parameter Passing

•Often, more information is required than simply identity ofdesired system call

•Exact type and amount of information vary according to OSand call

•Three general methods used to pass parameters to the OS

• Simplest: pass the parameters in registers

• In some cases, may be more parameters than registers

•Parameters stored in a block, or table, in memory, andaddress of block passed as a parameter in a register

•This approach taken by Linux and Solaris

• do not limit the number or length of parameters being passed

•Parameters placed, or pushed, onto the stack by the programand popped off the stack by the OS

• do not limit the number or length of parameters being passed

Page 22: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Parameter Passing via Table

Page 23: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Types of System Calls•Process control

• end, abort , load, execute ,create process, terminate process

• get process attributes, set process attributes

• wait for time, wait event, signal event, allocate and free memory

•File management• create file, delete file, open, close file.

• read, write, reposition, get and set file attributes

•Device management• request device, release device, read, write, reposition

• get and set device attributes , logically attach or detach devices

• Information maintenance• Get and set time or date, Get and set system data.

• get and set process, file, or device attributes

•Communications• create, delete connection, send, receive messages , transfer status

information , attach and detach remote devices

Page 24: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Examples of Windows and Unix System Calls

Page 25: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Single Tasking OS - Example: MS-DOS

• Shell (command interpreter) invokedwhen system booted

• Simple method to run program

• No process created

• Single memory space

• Loads program into memory,overwriting all but the kernel

• Next, it sets the instruction pointerto the first instruction of theprogram.

• Program exit -> shell reloaded

(a) At system startup (b) running a program

Page 26: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Multi-Tasking OS- Example: FreeBSD•Unix variant

•User login -> invoke user’s choice of shell

•Shell executes fork() system call to create process• Executes exec() to load program into

process

• Shell waits for process to terminate or continues with user commands

•Process exits with code of 0 – no error or > 0 – error code

Page 27: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

System Programs ( System Utility)

•Provide a convenient environment for program development and execution

•Some of them are simply user interfaces to system calls; others are considerably more complex

•File management - Create, delete, copy, rename, print, dump, list, and generally manipulate files and directories

•Status information

•System for info - date, time, available memory, disk space, number of users.

•performance, logging, and debugging information

•Typically, these programs format and print the output to the terminal or other output devices

•Some systems implement a registry - used to store and retrieve configuration information

Page 28: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

System Programs ( system Utility)

• File management - These programs create, delete, copy, rename, print,dump.

• Status information - Ask the system for the date, time, amount ofavailable memory or disk space, number of users, or similar statusinformation, logging, and debugging information, registry.

• File modification - Text editors to create and modify files and Specialcommands to search contents of files or modify of the text

• Programming-language support - Compilers, assemblers, debuggers.

• Program loading and execution - Absolute loaders, re-locatableloaders, linkage editors, and overlay-loaders, debugging systems forhigher-level and machine language

• Communications - Creating virtual connections among processes,users, and computer systems, Allow users to send messages to oneanother’s screens, browse web pages, send electronic-mail messages,log in remotely, transfer files from one machine to another

• Background services - All general-purpose systems have methodsfor launching certain system-program processes at boot time.

Page 29: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Operating-System Design and Implementation

•Define goals and specifications.

•The design of the system will be affected by the choice ofhardware and the type of system: batch, time sharing, singleuser, multiuser, distributed, real time, or general purpose.

•User goals:

•Convenient to use, easy to learn and use, reliable, safe, and fast.

•Designer goals:

• easy to design, implement, and maintain; and it should beflexible, reliable, error free, and efficient.

• System goals:

•Resource allocator and device manager

•No unique solution to the problem of defining OS requirements.

•Because operating systems are collections of many programs,written by many people over a long period of time, it is difficultto make general statements about how they are implemented.

Page 30: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Structure - Simple Structure – MS DOS• Provide most functionality in the least space, Not divided into modules

• Its interfaces and levels of functionality are not well separated

• Application programs are able to access the basic I/O routines to write directly

to the display and disk drives vulnerable to errant (or malicious) programs,

causing entire system crashes when user programs fail

• no dualmode and no hardware protection,

Page 31: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Structure – Limited Structure – UNIX OS• Consists of two separable parts: the kernel and the system programs.

• The kernel is further separated into a series of interfaces and devicedrivers, which have been added and expanded over the years as UNIXhas evolved.

Page 32: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Structure - Layered Approach• The OS 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

Page 33: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Structure – Micro Kernel• Divide the kernel into microkernels by removing all nonessential

components from the kernel to the system and user-level (Mach OS1980).

• Minimal process and memory management, communication facility.

• The performance of microkernels can suffer due to increased system-function overhead (win NT 4, enhanced in Win95 and windows XP)

Page 34: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Structure – Mac OS X Structure

Page 35: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Structure – Modules

•Most modern OS's implement kernel modules• Uses object-oriented approach• Each core component is separate• Each talks to the others over known interfaces• Each is loadable as needed within the kernel

•Overall, similar to layers but with more flexible

Solaris Modular Approach

Page 36: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Structure – Hybrid systems

• Combine different structures resulting in hybrid systems that address performance, security, and usability issues

Page 37: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Virtual Machines

•A virtual machine takes the layered approach.

• a single physical machine can run multiple operating systemsconcurrently, each in its own virtual machine.

•Divide the hardware of a single computer (the CPU, memory, diskdrives, network interface cards, ..) into several different executionenvironments, thereby creating the illusion that each separateexecution environment is running its own private computer.

•Benefits:

• able to share the same hardware

• the host system is protected from the virtual machines

• define a network of virtual machines and enable each machine to send information over the virtual communication network.

• Changing an operating system is a difficult task.

Page 38: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Virtual Machines (Cont.)

(a) Non-virtual machine (b) virtual machine

Page 39: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

VM Where Work Station

• Popular commercial application that abstracts Intel X86 and compatible hardware into isolated virtual machines.

• Runs as an application on a host OS such as Windows or Linux and allows this host system to concurrently run several different guest OSs as independent virtual machines.

Page 40: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Java• Java is a technology introduced by Sun Microsystems in the mid-1990s.

• Java technology consists of two essential components:

1. Java Programming-language specification

• Java is a general-purpose, OOP language with support for distributed programming.

• Java was originally favored by the Internet programming community because of its support for applets, which are programs with limited resource access that run within a Web browser.

• Used to design desktop applications, client–server Web applications, and embedded systems such as smartphones.

• Programs are consists of more than one class (java compiler produces .class)

• Multithreaded language

• Development of concurrent applications to take advantage of modern processors with multiple processing cores.

• Secure language ( so it can be executed over a distributed network)

Page 41: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Java

2. Java Virtual Machine

• Its an abstract of computer and consists of a class loader and Java

interpreter

• The class loader loads the compiled .class files from both the Java

program and the Java API for execution by the Java interpreter.

• The .class file is verified.

• After Verification it run by the Java interpreter.

• JVM also manages memory by performing garbage collection

Page 42: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Java3. Java Development Kit (JDK): consists of

• development tools, such as a compiler and debugger, and turns a Java source

file program into a byte code (.class) file

• Java Run-time environment(JRE): provides the JVM as well as the Java API

for the host system.

Page 43: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

Operating-System Debugging

•Debugging is finding and fixing errors, or bugs

•OS’s generate log files containing error information

• Failure of an application can generate core dump file capturingmemory of the process generated by the OS.

• Performance tuning can optimize system performance

•Kernighan’s Law: “Debugging is twice as hard as writing the codein the first place. Therefore, if you write the code as cleverly aspossible, you are, by definition, not smart enough to debug it.”

•DTrace tool in Solaris, FreeBSD, Mac OS X allows liveinstrumentation on production systems

• Probes fire when code is executed, capturing state data andsending it to consumers of those probes.

Page 44: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

OS Generation• OS's are designed to run and configured on any of a class of machines;

• The operating system is normally distributed on disk, on CD-ROM orDVD-ROM, or as an “ISO” image, which is a file in the format of aCD-ROM or DVD-ROM.

• SYSGEN program obtains information concerning the specificconfiguration of the hardware system

• What CPU is to be used? For multiple CPU systems, each CPU maybe described.

• How will the boot disk be formatted? How many sections, or“partitions,” will it be separated into?

• How much memory is available?

• What devices are available?

• What OS options are desired?

Page 45: Designed and Presented by Dr. Ayman Elshenawy Elsefy · environment and almost never use the MS-DOS CLI. •System administrators who manage computers and power users who have deep

System Boot

•OS must be made available to hardware so hardware can start it

•booting the system is the procedure of starting a computer by loading the kernel

•Bootstrap program – bootstrap loader locates the kernel, loads it into main memory, and starts its execution.

•When power initialized on system, execution starts at a fixed memory location in read-only memory (ROM), or Firmware used to hold initial boot code


Recommended