1 / 41

Operating Systems and Linux

Operating Systems and Linux. Partha Sarathi Dasgupta MIS Group Indian Institute of Management Calcutta. What does an Operating System do?. An Operating System exploits the hardware resources of one or more processors to provide a set of services to system users.

beulah
Télécharger la présentation

Operating Systems and Linux

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating Systems and Linux Partha Sarathi Dasgupta MIS Group Indian Institute of Management Calcutta

  2. What does an Operating System do? • An Operating System exploits the hardware resources of one • or more processors to provide a set of services to system users. • An Operating System also manages secondary memory and • input/output devices on behalf of its users.

  3. Structural Elements of a Computer • Processor: Controls the operation of the computer and its • Data Processing functions.. A single processor is often termed as • the Central Processing Unit. • Main memory: Stores data and programs. This memory is • typically volatile. Contents of disk memory are retained even • when the computer is shut down. • I/O modules: Moves data between the computer and its external • environment, such as disks, data communication equipments, • and terminals. • System bus: Provides for communication between processors, • main memory, and I/O modules.

  4. Structural Elements of a Computer: Schematic view CPU 0 1 MAR PC 2 MBR Instruction IR Instruction I/O AR Instruction I/O BR Execution Data Data Data Data n -2 Buffers n -1 Input-Output Module

  5. Interrupts • A mechanism by which other modules (I/O, memory) may • interrupt the normal sequencing of the processor • Interrupts help to improve processor utilization. • Classes of interrupts: • Program: generated by some condition that occurs as a result of an instruction execution, such as arithmetic overflow, division by zero, attempt to execute an illegal machine instruction, and reference outside a user’s allowed memory space. • Timer: Generated by a timer within the processor. This allows the operating system to perform certain functions regularly. • I/O: Generated by an I/O controller, to signal normal completion of an operation or to signal a variety of error conditions. • H/W failure: Generated by a failure, such as power, etc.

  6. An Example • A processor has two programs P1 and P2 to execute: • P1 is simply reading data from memory and writing the data into • the disk. P2 is doing only calculations. • Processor may begin P1 first, issue a write command to the • external device, and then proceed with P2. • Two cases: • Writing to disk initiated by P1 might finish before P2 completes • calculations. • P2 completes calculations before the disk writing initiated by • P1 finishes. • What are the consequences of these two cases?

  7. Memory Hierarchy Registers Cache Main Memory Magnetic disk, CD-ROM, CD-RW DVD-RW, DVD-RAM Magnetic tape

  8. Cache • a portion of the main memory that can be used as a buffer • temporarily holds data that are to br read out to disk • Caches improve the performance in two ways: • Disk writes are clustered. • instead of having many small transfers of data, few large transfers are possible. • some data meant for write-out (from disk) may be directly accessed from the cache very fast.

  9. Operating System • It is a program that • controls the execution of application programs • acts as an interface between applications and computer hardware • manages the resources associated with a computer Objectives of an O.S. • Convenience of use of the computer • Efficient use of the computing resources • Should be such that it can permit effective development, testing and introduction of new system functions without affecting he service.

  10. Operating System as an Interface Application Programs End user Utilities Programmer Operating System OS System Designer Computer Hardware

  11. Operating System Services • Program Development – variety of services and utilities such as • Editors and debuggers. They are usually referred to as application program • development tools. • Program Execution – involves a number of steps, such as loading • Instruction and data in the main memory, initialisation of I/O devices and files, and other resources to be allocated. OS handles the scheduling. • Access to I/O devices – Each I/O device has its own set of • Instructions and control signals. O.S. hides these details to provide a • common interface to the user/programmer.

  12. Operating System Services • Controlled access to files- nature of I/O device (disk drive, tape drive) and structure of the data stored in the files in the storage medium. In the case of multiple users accessing the processor concurrently, proper protection mechanisms have to be used. • System access- For shared or public systems, the O.S. controls access to the system as a whole and to specific system resources. Access system provides protection of resources, and data from unauthorised users, and resolves resource conflicts • Error detection and response – Variety of errors may occur in computer system. Responses may range from program termination, retrial of the same operation, or reporting error to the application. • Accounting – collecting usage statistics, CPU usages, monitor • performance, etc.

  13. Evolution of Operating Systems • Serial Processing • From 1940s to mid-1950s • Programmer interacted with the hardware • Programs in machine code were loaded via the input device (card reader) • In case of any error, they were indicated with lights Associated problems: • Scheduling: Hardcopy sigh-up sheet for reserving time • User could reserve for 45 mins and finish in 30 mins => wastage of time • User may not be able to finish in scheduled time

  14. Evolution of Operating Systems • Simple Batch Processing • for maximizing machine utilisation • batch O.S. used • a piece of software called the monitor used • monitor reads in jobs one at a time from the input device • as a job is read in, control is passed to the current job; control returns back to the monitor when the job is finished • results of a job are sent to an output device such as the printer • Processor is executing the instructions from those of the monitor • Processor will then execute the instruction of the user program until it encounters an ending or error condition • instructions for the monitor are contained in the JCL monitor Interrupt processing Device drivers Job sequencing Control language interpreter User Program Area

  15. Modes of a user program • A user program executes in user mode, in which certain areas • of memory are protected from the user’s use, and • certain instructions may not be executed. • monitor executes in a system mode, or a kernel mode, in which privileged instructions may be executed and protected memory segments accessed. • Batch O.S. – machine time alternates between monitor and the user programs. • Effect: some memory given to the monitor, and some of the machine time is consumed by the monitor.

  16. An example of System Utilization Read one record from a file = 19 μs Execute 100 instructions = 2 μs Write one record to a file = 19 μs --------- TOTAL 40 μs Percent CPU utilization = 2/40 = 0.005 = 0.5%

  17. An example of Multiprogramming P1 Run Wait Run Wait Wait Wait Wait Run Run P2 Wait P3 Run Wait Run Wait Wait Wait P1, P2, P3 Run Run Run Run Run Run Any Advantage?

  18. Multiprogramming/Multitasking: Some Figures • Multiprogramming Operating systems are more complex • Memory management • Scheduling Uniprogramming Multiprogramming Processor use 20% 40% Memory use 33% 67% Disk use 33% 67% Printer use 33% 67% Elapsed time 30 min 15 min Throughput 6 jobs/hr 12 jobs/hr Mean response time 18 min 10 min Effect of Multiprogramming on Resource Utilization

  19. Time-Sharing Systems • For some jobs, e.g., for transaction processing jobs, it is desirable that users may interact directly with the computer • Processor time is shared among multiple users through time sharing • multiple users simultaneously access the system through terminals, with the O.S. interleaving the execution of each user program in time quanta. • For n users actively requesting service at one time (for instance, all editing files), each user will only see on the average 1/n of the effective computer capacity (approx.) • Given the slow human reaction time, response time is similar to that on a dedicated machine

  20. Multiprogramming and Time-Sharing • Multiprogramming maximises CPU utilization • Time-sharing minimizes user response rime • What about the Throughput?

  21. Major theoretical advances in development of O.S. • Processes • Memory management • Information protection and security • Scheduling and resource management • System structure

  22. Processes • A process is • a program in state of execution • An instance of a program running on a computer • The entity that can be assigned to and executed on a processor • A unit of activity characterised by a single sequential thread of execution, a current state, and an associated set of system resources

  23. Why Processes need to be scheduled? • Improper synchronization: for example, a process that initiates an I/O read must wait until the data are available in a buffer. This requires signal from some other process. • Mutual exclusion: multiple users might try to access a shared resource concurrently, e.g., editing the same file at the same time. Mutual exclusion mechanism required. • Non-determinate program operation: Results of a program normally depend on the input to that program only. When programs share memory, and their execution is interleaved by the processor, they may interfere with each other. Order of program execution may affect the execution of a particular program. • Deadlock: It is possible for two or more programs to be hung up waiting for each other.

  24. Parts of a Process • Components of a process • An executable program • Associated data required by the program (variable, work space, buffer, etc.) • Execution context: internal data used by O.S. to supervise a process = process state. Process list Main memory data context context data Program code Program code

  25. Process Control Block • Identifier: A unique integer associated with a process • State : A currently executing process is in running state • Priority : Priority level relative to other processes • Program counter : Address of the next instruction of the • program to be executed. • Memory pointers: pointers to the program code and data • associated with the process, and any shared memory blocks • Context data: Data in the registers in the processor during • process execution. • I/O status information: outstanding I/O requests, I/O devices • allocated to the process, a list of files is use by the process, etc. • Accounting information: amount of processor time, etc.

  26. Key responsibilities of Resource management • O.S. manages the resources of a computer system • Factors for scheduling policy: • Fairness: processes competing for a resource should be given fair chance of resource access • Differential responsiveness: O.S. should make allocation and scheduling decisions to meet total set of requirements, and in a dynamic manner. E.g., if a process is waiting for an I/O device, O.S. may schedule that process as soon as the device is free. • Efficiency: Maximize throughput, minimize response time, and accommodate as many concurrent users as possible.

  27. Virtual Memory • A facility that allows programs to address memory from a logical viewpoint • Disregards the amount of physical memory actually available • Meets the requirements of multiple user processes to reside simultaneously in main memory without any interference • (Demand) Paging system and Page faults • Address of a word of a program = page number + offset within page • Pages vs Blocks mapping

  28. Problem of contiguous block assignment File A File B File C 10 20 30 Is the contiguous block allocation OK?

  29. Why use Linux/Unix? • System is written in a high-level language => easy to read, understand, change and port to other machines. • Simpler user interface or user services • Provides simple routines to write complex programs/develop utilities • Hierarchical file system for easy maintenance • Consistent format for files (byte streams) making application development easier • Simple, consistent interface to peripheral devices

  30. UNIX Architecture • Kernel • Shell • Utilities Application Programs UNIX commands and libraries System call interface bash H/W who Kernel wc vi

  31. Traditional Unix Kernel User programs Libraries User level Kernel level System call interface File subsystem IPC Process control subsystem Buffer cache scheduler Character Block Memory management Device drivers Hardware control Kernel level Hardware level Hardware

  32. Some Basic Characteristics of Linux • Multi-user System • Multiprogramming/Multitasking system • Uses Time Sharing • Access rights for Files and Processes • Uses File and Process hierarchies

  33. Linux File System • Characteristics: • Hierarchical structure • Consistent treatment of file data • Ability to create, modify and delete files • Dynamic growth of files • Protection of file data • Treating peripheral devices (terminals, tapes, etc.) as files

  34. Linux File System Layout (RedHat)

  35. Directory Structure of Linux File System

  36. Directory Structure of Linux File System

  37. Mounting of file systems etc usr usr harry tom

  38. Types of files in a Linux System • "On a UNIX system, everything is a file; if something is not a file, it is a process." • Regular files : they contain normal data, for example text files, executable files or programs, input for or output from a program and so on. • Directories: files that are lists of other files. • Special files: Devices treated as files, used for input and output. They exist in /dev. • Links: a system to make a file or directory visible in multiple parts of the system's file tree. • (Domain) sockets: a special file type, similar to TCP/IP sockets, providing inter-process networking protected by the file system's access control. • Named pipes: act more or less like sockets and form a way for processes to communicate with each other, without using network socket semantics.

  39. Permissions of a file • Read • Write • execute

  40. Listing files in a Linux System The -l option to ls displays the file type, using the first character of each input line:

  41. User Accounts • login nmes • passwords • user id • group id • Home directory

More Related