Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Similar documents
Chapter 2: Operating-System Structures. Operating System Concepts Essentials 8 th Edition

Chapter 2: Operating-System

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures

Chapter 2: System Structures

CHAPTER 2: SYSTEM STRUCTURES. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

CS307: Operating Systems

Chapter 2: Operating-System Structures. Chapter 2: Operating-System Structures. Objectives. Operating System Services

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edition

Chapter 2: System Structures. Operating System Concepts 9 th Edition

Objectives. Chapter 2: Operating-System Structures. 2.1 Operating System Services

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edit9on

Chapter 2. Operating-System Structures

Operating-System Structures

Chapter 2: System Structures. Operating System Concepts 9 th Edition

Lecture 2 Operating System Structures (chapter 2)

CS420: Operating Systems. OS Services & System Calls

Chapter 2 Operating-System Structures

TDDI04, K. Arvidsson, IDA, Linköpings universitet Operating System Structures. Operating System Structures Overview. Operating System Services

The Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams.

Chapter 2: Operating-System Structures. Operating System Concepts 8 th Edition

Chapter 2: System Structures

Chapter 2 Operating System Structures

Introduction to PC Operating Systems

Operating-System Structures

Chapter 2. Operating System Structures

Operating System Services. User Services. System Operation Services. User Operating System Interface - CLI. A View of Operating System Services

Operating System Services

CS370 Operating Systems

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Chapter 2: OS Structures

OPERATING SYSTEMS. Prescribed Text Book Operating System Principles, Seventh Edition By Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edit9on

Kernel Types Simple OS Examples System Calls. Operating Systems. Autumn CS4023

CSE 4/521 Introduction to Operating Systems

Lecture 2 - Fundamental Concepts

Four Components of a Computer System

What are some common categories of system calls? What are common ways of structuring an OS? What are the principles behind OS design and

Operating System: Chap2 OS Structure. National Tsing-Hua University 2016, Fall Semester

Chapter 3: Operating-System Structures

Often, more information is required when designing system call Information varies according to OS and types of system call

UNIT 2. OPERATING SYSTEM STRUCTURES

Full file at

Chapter 3: Operating-System Structures

Chapter 3: Operating-System Structures

OPERATING SYSTEMS Lecture Notes. Prepared by K.Rohini, Assistant Professor, CSE Department, GVPCEW.

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management

Operating-System Structures

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

Module 3: Operating-System Structures. Common System Components

Introduction to Operating Systems (Part III)

Module 3: Operating-System Structures

Module 1 Introduction/OS Overview

CSE Opera+ng System Principles

What we saw. Desarrollo de Aplicaciones en Red. 1. OS Design. 2. Service description. 1.1 Operating System Service (1)

CSC Operating Systems Spring Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. January 17 th, 2007.

Announcements. Operating System Structure. Roadmap. Operating System Structure. Multitasking Example. Tevfik Ko!ar

! Software ( kernel ) that runs at all times. ! OS performs two unrelated functions: Maria Hybinette, UGA. user! 1! Maria Hybinette, UGA. user! n!

Chap2: Operating-System Structures

Architectural Support for Operating Systems. Jinkyu Jeong ( Computer Systems Laboratory Sungkyunkwan University

Operating-System Structures

PG-TRB COMPUTER INSTRUCTOR OPERATING SYSTEMS

OS Structures. ICS332 Operating Systems

CSCI 6730 / 4730 Operating Systems. Key Questions in System Design. Review: What is An Operating System? Key Points

Chapter 3 Process Description and Control

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Operating Systems. Operating System Structure. Lecture 2 Michael O Boyle

Operating System Structure

Operating- System Structures

OPERATING SYSTEMS UNIT - 1

Operating System Concepts Ch. 2: Operating System Structures

Operating Systems CS3502 Spring 2018

CSCA0201 FUNDAMENTALS OF COMPUTING. Chapter 6 Operating Systems

Chapter 2: Operating-System Structures

OS structure. Process management. Major OS components. CSE 451: Operating Systems Spring Module 3 Operating System Components and Structure

Operating System Architecture. CS3026 Operating Systems Lecture 03

Operating systems Architecture

OS concepts and structure. q OS components & interconnects q Structuring OSs q Next time: Processes

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - VII CPU Scheduling - II. Louisiana State University

Roadmap. Multilevel Queue Scheduling. Multilevel Queue. Example of Multilevel Feedback Queue. Multilevel Feedback Queue. Tevfik Ko!

Operating System Review

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System

About the Presentations

Operating System Structure

Operating Systems Overview. Chapter 2

Operating System. Operating System Overview. Layers of Computer System. Operating System Objectives. Services Provided by the Operating System

Operating System Overview. Operating System

Download from Powered By JbigDeaL

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

Introduction to Java Programming

Process Description and Control

Operating System Structure

CS 300 Leftovers. CS460 Pacific University 1

OPERATING SYSTEMS: Lesson 1: Introduction to Operating Systems

Chapter 8 Operating Systems and Utility Programs

Transcription:

Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference Operating System Concepts, ABRAHAM SILBERSCHATZ

Chapter 2: Operating-System Structures

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

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 and programmers; 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 users of those programs ) OS services differ from one to another, but we can identify common classes Operating system services are: Functions that are helpful to the user Functions for ensuring efficient operation of the system.

OS Services

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 cursors and 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 a display screen). File-system manipulation: How programs are used to create file, write, read, extend, delete files and directories, search them, list file Information, permission and properties of these files.

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 paper in the printer). User program errors (arithmetic overflow, attempt to access an illegal memory location, or a too-great use of CPU time). Debugging facilities can greatly enhance the user s and programmer s abilities to use the system efficiently.

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 to improve 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 the OS itself. Protection involves ensuring that all access to system resources is controlled. Security of the system from outsiders is also important (user authentication, user name and password).

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 the CLI depends on the number of commands that can be given (each command have its code) implements most commands through system programs, (programmers can add new commands to the system easily by creating new files with the proper names.) in this case the command interpreter does not understand the command, it merely uses the command to identify a file to be loaded into memory and executed. Thus, the UNIX command to delete a file (rm is added as a system program) rm file.txt

Bourne Shell Command Interpreter

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)

The Mac OS X GUI

OS Interface Choice of Interface Is mostly one of personal preference. Most Windows users are happy to use the Windows GUI environment and almost never use the MS-DOS CLI. System administrators who manage computers and power users who have deep knowledge of a system frequently use the 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 be run just like a program. The program is not compiled into executable code but rather is interpreted by the CLI. These shell scripts are very common on systems that are command-line oriented, such as UNIX and Linux. The design of a useful and friendly user interface is therefore not a direct function of the operating system (but providing an adequate service to user programs).

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 copy them 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 two files (may be selected by mouse). 3. Open the input file (check error not exist or protected) if Error print message and terminate. 4. If the input file exists, then create a new output file (check error file exist, no memory). Abort if error exist, may delete the existing file and create a new one. 5. loop that reads from the input file (a system call) and writes to the output file (another system call). 6. close both files (another system call) 7. write a message to the console and terminate normally.

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

System Calls Systems execute thousands of system calls per second and most programmers never see this level of detail. Application developers design programs according to an application programming interface (API). The API specifies a set of functions that are available to an application programmer, including the parameters that are passed to each function and the return values the programmer can expect. Three of the most common APIs available to application programmers: Win32 API for Windows, POSIX API for POSIX-based systems (which include virtually all versions of UNIX, Linux, and Mac OS X), Java API for designing programs that run on the Java virtual machine.

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

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 interface that links to system calls made available by the OS. The system-call interface intercepts function calls in the API and invokes the necessary system calls within the OS. A number is associated with each system call, and the system call interface maintains a table indexed according to these numbers. The caller need know nothing about how the system call is implemented or what it does during execution. It needs only to obey the API standard. Thus, most of the details of the operating-system interface are hidden from the programmer by the API and are managed by the run-time support library.

API System Call OS Relationship The relationship among an API, the system-call interface, and the OS. Standard C Library Example C program invoking printf() library call, which calls write() system call

System Call Parameter Passing Often, more information is required than simply identity of desired system call Exact type and amount of information vary according to OS and 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, and address 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 program and popped off the stack by the OS do not limit the number or length of parameters being passed

Parameter Passing via Table

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

Examples of Windows and Unix System Calls

Single Tasking OS - Example: MS-DOS Shell (command interpreter) invoked when 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 pointer to the first instruction of the program. Program exit -> shell reloaded (a) At system startup (b) running a program

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

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

System Programs ( system Utility) File management - These programs create, delete, copy, rename, print, dump. Status information - Ask the system for the date, time, amount of available memory or disk space, number of users, or similar status information, logging, and debugging information, registry. File modification - Text editors to create and modify files and Special commands to search contents of files or modify of the text Programming-language support - Compilers, assemblers, debuggers. Program loading and execution - Absolute loaders, re-locatable loaders, linkage editors, and overlay-loaders, debugging systems for higher-level and machine language Communications - Creating virtual connections among processes, users, and computer systems, Allow users to send messages to one another 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 methods for launching certain system-program processes at boot time.

Operating-System Design and Implementation Define goals and specifications. The design of the system will be affected by the choice of hardware and the type of system: batch, time sharing, single user, 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 be flexible, 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 difficult to make general statements about how they are implemented.

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,

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 device drivers, which have been added and expanded over the years as UNIX has evolved.

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

OS Structure Micro Kernel Divide the kernel into microkernels by removing all nonessential components from the kernel to the system and user-level (Mach OS 1980). Minimal process and memory management, communication facility. The performance of microkernels can suffer due to increased systemfunction overhead (win NT 4, enhanced in Win95 and windows XP)

OS Structure Mac OS X Structure

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

OS Structure Hybrid systems Combine different structures resulting in hybrid systems that address performance, security, and usability issues

Virtual Machines A virtual machine takes the layered approach. a single physical machine can run multiple operating systems concurrently, each in its own virtual machine. Divide the hardware of a single computer (the CPU, memory, disk drives, network interface cards,..) into several different execution environments, thereby creating the illusion that each separate execution 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.

Virtual Machines (Cont.) (a) Non-virtual machine (b) virtual machine

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.

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)

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

Java 3. 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.

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 capturing memory of the process generated by the OS. Performance tuning can optimize system performance Kernighan s Law: Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. DTrace tool in Solaris, FreeBSD, Mac OS X allows live instrumentation on production systems Probes fire when code is executed, capturing state data and sending it to consumers of those probes.

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 or DVD-ROM, or as an ISO image, which is a file in the format of a CD-ROM or DVD-ROM. SYSGEN program obtains information concerning the specific configuration of the hardware system What CPU is to be used? For multiple CPU systems, each CPU may be 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?

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