710 likes | 735 Views
Chapter 1 Basic Concepts of Operating Systems. Software. A program is a sequence of instructions that enables the computer to carry out some specific task.
E N D
Software • A program is a sequence of instructionsthat enables the computer to carry out some specific task. • Before a program executes, it has to be translated from its original text form (source program/code) into a machine languageprogram (object program/code). Then, the program needs to be linked and loaded into memory.
Software Components • The software components are the collection of programs that execute in the computer. • These programs perform computations, control, manage, and carry out other important tasks. • Two general types of software components are: • System software • Application software
System Software • The system software is the set of programs that control the activities and functions of the various hardware components, programming tools and abstractions, and other utilities to monitor the state of the computer system. • The system software forms an environment for the programmers to develop and execute their programs (collectively known as application software). • Three types of users can be identified: system programmers, application programmers and end-users.
Application Software • Application software are the user programs and consist of those programs that solve specific problems for the users and execute under the control of the operating system. • Application programs are developed by individuals and organizations the ways in which the system resources are used to solve the computing problems of the users • Word processors, compilers, web browsers, database systems, video games • Users • People, machines, other computers
Computer System Structure • Computer system can be divided into four components: • Hardware – provides basic computing resources • CPU, memory, I/O devices • System software - Operating System, Assemblers, Loaders, Linkers, Compilers, Editors, … • Operating system • Controls and coordinates use of hardware among various applications and users • Application programs – All User-Oriented Programs, which define the ways in which the system resources are used to solve the computing problems of the users • Word processors, compilers, web browsers, database systems, video games • Users • People, machines, other computers
Computer System Structure • System software - Operating System, Assemblers, Loaders, Linkers, Compilers, Editors, … • Application software - All User-Oriented Programs. SYSTEM and APPLICATION PROGRAMS Users SYSTEM PROGRAMS/OS HARDWARE
Operating System Definition (Cont.) No universally accepted definition “Everything a vendor ships when you order an operating system” is a good approximation But varies wildly “The one program running at all times on the computer” is the kernel. Everything else is either a system program (ships with the operating system) , or an application program.
External View of a Computer Kernel
What is an Operating System? • A large and complex set of softwarecomponent for the operation and control of the computer system. Availability of services and Management of the computer resources • OS is a resource allocator • Manages all resources • Decides between conflicting requests for efficient and fair resource use • OS is a control program • Controls execution of programs to prevent errors and improper use of the computer • It acts as an intermediary between a user and the computer system.
Design Goals • User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast. • System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient.
What Operating Systems Do • Depends on the point of view • Users want convenience, easeofuse and good performance • Don’t care about resourceutilization • But shared computer such as mainframe or minicomputer must keep all users happy • Users of dedicate systems such as workstations have dedicated resources but frequently use shared resources from servers • Handheld computers are resource poor, optimized for usability and battery life • Some computers have little or no user interface, such as embedded computers in devices and automobiles
Operating Systems User Interfaces User and application programmers can communicate with OS via interface Three levels of interface: • Graphical User Interface: GUI (windows oriented) • Command line level interpreter (also known as the shell). At login time, the shell starts computing • System calls interface invoked from user programs
Basic Structure of an OS The GUI and the Shell are at the same level in the structure of an OS
GUI • The first and the highest level of is the GUI • Allow interaction via icons, menu, and other graphical objects • This level of OS interface is not considered as essential part of the Operating System, it is rather an add-on system software component.
The Shell • The second level of interface, the command line interpreter, or Shell program that handles user interaction with the system is called: • Shell • Command-line interpreter • Two types of Shells • Graphical • Character oriented
System Calls • The third level, the System –call interface, is used by the application programs to request services provided by the OS by invoking or calling system functions. This is also known as the Application Programming Interface (API) • Programs use the API to request the OS to perform some function
Common Functions of Interrupts Interrupt transfers control to the interrupt service routine generally, through the interruptvector, which contains the addresses of all the service routines Interrupt architecture must save the address of the interrupted instruction A trap or exception is a software-generated interrupt caused either by an error or a user request An operating system is interrupt driven
Interrupt Handling The operating system preserves the state of the CPU by storing registers and the program counter Determines which type of interrupt has occurred: polling vectored interrupt system Separate segments of code determine what action should be taken for each type of interrupt
Multi-Level Views • The overall structure of an operating system is divided into the various software components using a top-down (layered) approach. • The top layer provides the easiest interface to the human operators and users interacting with the system. • Any layer uses the services or functions provided by the next lower layer.
Operating Systems Abstract Views • External views (Sometimes refer to as the abstract views) • Abstraction provides by the OS interfaces gives users and application programs the appearance of a simpler machine. • Set of interface of the computer system • A layer of software on top of the hardware • Internal view • System call interface separates the kernel from the application layer • Resource manager - It controls and manages CPU, memory, I/O devices, etc.
Transition from User to Kernel Mode Timer to prevent infinite loop / process hogging resources Timer is set to interrupt the computer after some time period Keep a counter that is decremented by the physical clock. Operating system set the counter (privileged instruction) When counter zero generate an interrupt Set up before scheduling process to regain control or terminate program that exceeds allotted time
Layered Structure of an OS • Users (top layer) • Application User Interface (AUI): shell, commands, application programs • Application program Interface (API): libraries, system calls • OS kernel
Internal View of an Operating System • The system call interface separates thekernelfrom the application layer and the kernel is located above the hardware • The kernel is the core and most critical part of the operating system and needs to be always resident in memory. • A detailed knowledge about the different components, including these lower-level components of the operating system, correspond to an internal view of the system.
Functional Components of an OS The most important components of an operating system are: • Process manager • Memory manager • Resource manager • File manager • Device manager
Services Provided by the OS • Process Control, execution, scheduling, etc. • Communication between processes • File Manipulation • Device Manipulation • Information Maintenance • Memory Management
Jobs and Processes A job is a unit of work submitted by a user to the operating system. A typical job consists of the parts listed below: • A sequence of commands to the operating system • A program either in a source language or in binary form • A set of input data used by the program when it executes A process basically refers to an execution instance of a program.
Categories of Operating Systems • Batch systems, in which a set of jobs are submitted in sequence for processing. The system have long average turnaround period (interval from job arrival time to completion time) of jobs. • Interactive systems, which support computing for on-line users. The most common type of operating systems that support interactive computing is time-sharing, which are multi-user systems. • Real-time systems, which support application programs with very tight timing constraints. • Hybrid systems, which support batch and interactive computing.
Jobs • The term job refers to a unit of work submitted by a user to the operating system. • A typical job consist of the following: • A sequence of commands to the OS • A program either in a source language or in binary form • A set of input data used by the program when it executes
History of Operating Systems • First generation - No operating system, bare hardware, machine language. • Second generation • Batch systems, assemblers, linkers, loaders, compilers • Batch systems with Automatic Job Sequencing
History of Operating Systems(2) • Third generation -- O.S. for complete families of computers (OS/360) • Batch with Multiprogramming • Spooling • Timesharing (MULTICS, UNIX, …) • Fourth generation • Network and distributed operating systems
Modern Operating Systems • Windows (Microsoft Corporation) these include a family of systems: 98, Me, CE, 2000, XP, Vista, Windows 7, and others • Linux (Linus Torvalds, OSF GNU) • MacOS (Apple) • Solaris (Sun Microsystems) • OSF-1 (OSF, DEC) • IRIX (Silicon Graphics) • OS2 (IBM) • OS/390 (IBM) • VMS (Dec/Compaq/HP)
System Implementation • Traditionally written in assembly language, operating systems can now be written in higher-level languages. • Code written in a high-level language: • can be written faster. • is more compact. • is easier to understand and debug. • An operating system is far easier to port (move to some other hardware) if it is written in a high-level language.
Processes & Threads • Processes and threads are two important types of dynamic entities in computer system. • A Process is a the execution of a Program; More specifically… • A process is a program in memory either • in execution • waiting for CPU, I/O, or other service.
Process Management • A process can contain one or more threads of execution in order to execute, partially is waiting for other services in the computer system. • An important function of the OS are: • It involves creating processes and controlling their execution • The OS manages several processes in memory at the same time • The processes share the system resources --- multiprogramming
Processes • Two important types of dynamic entities in a computer system are processes and threads. • The state changes are really controlled by the OS • When the process is needs a resources and is NOT available, the processes changes from one state of changes from the running state to the waiting for resource state • Then a process is waiting for service from the CPU, it is placed in the ready queue and is in the ready state. • Also, when a process is waiting in I/O service, it is placed in one of several I/O queue and it changes to wait state.
Process Creation • On a typical operating system, a process is created • In response to a new job arriving • A new user who carries out a login • A currently executing process that creates a new process. • A process is created if there is sufficient memory available, and the process waits if other resources it needs are not available.
Process Behavior • A process requests CPU and I/O processing at various times and usually will have to wait for these services. • The OS maintains a waiting line or queue of processes for every one of these services. • At some point in time, the process will be in a queue waiting for CPU service. At some other point in time, the process will be in a different queue waiting for I/O service. • When the process completes all service requests, it terminates and exits the system.
Process States • Created • Ready (waiting in the ready queue for the CPU) • Running (executing) • Blocked (suspended and waiting for I/O or other event) • I/O processing • Waiting for passive resources • Interrupted by the OS • Terminated
Process State Diagram • Represents the various states of a process and the possible transitions in the behavior of a process. • Each state is indicated by a rounded rectangle and the arrows connecting the states are the transitions from one state to the next. • The small black circle denotes that the state it points to is the initial state. • In a similar manner, the state before the hollow small circle indicates that it is the last state in the behavior of a process. • Normally a process spends a short finite time in any of its states.
Process State-Transition Diagram Process is created. In a time-sharing system, user logs New process is created. Process is ready and waits for CPU services Initial State The state in which a program is waiting for I/O service is normally called the block state After satisfying all service requests, the process terminates It is possible wait state is defined when the process is swappedout to disk, if there is not sufficient memory. Last State
Process Descriptor • Fro every new process in the system, a data structure called Process Descriptor, also known as a process control block (PCB) • The behavior of this process is that when the process terminates, its descriptor is normally destroyed.
Data in a Process Descriptor Each process is represented by its own PCB • Process name • Process state • Program counter, CPU registers • I/O status • Memory information • Accounting information • Scheduler information (priority, queues, …) • List of resources
Threads • Modern OS supports computational units called threads. • A process can have multiple threads or sequences of executions. • Threads often called: • A light-weight process • A single execution sequence • A component of a process • Shares with other threads code and resources allocated to the process • Most OSs support multi-threading: several threads in a single process
MultiThreading • In addition to multiple processes, newer operating systems support other computational units called threads. • A thread is called a lightweight process and is a dynamic component of a process. • The OS manages processes and threads in a multiprogramming environment.