This document is a disclaimer for a presentation. It states that materials from various online sources like books, websites, and research papers were used to create the slides, but the author does not intend to take credit for or profit from those sources. The presentation is intended solely for educational purposes and does not infringe on any copyrights. Sources are acknowledged where applicable. The views expressed are the presenter's alone and do not represent the actual authors or institution.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
14 views69 pages
OS Lec-2
This document is a disclaimer for a presentation. It states that materials from various online sources like books, websites, and research papers were used to create the slides, but the author does not intend to take credit for or profit from those sources. The presentation is intended solely for educational purposes and does not infringe on any copyrights. Sources are acknowledged where applicable. The views expressed are the presenter's alone and do not represent the actual authors or institution.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 69
DISCLAIMER
In preparation of these slides, materials have been taken from
different online sources in the shape of books, websites, research papers and presentations etc. However, the author does not have any intention to take any benefit of these in her/his own name. This lecture (audio, video, slides etc) is prepared and delivered only for educational purposes and is not intended to infringe upon the copyrighted material. Sources have been acknowledged where applicable. The views expressed are presenter’s alone and do not necessarily represent actual author(s) or the institution. 2 DISCLAIMER
In preparation of these slides, materials have been taken from
different online sources in the shape of books, websites, research papers and presentations etc. However, the author does not have any intention to take any benefit of these in her/his own name. This lecture (audio, video, slides etc) is prepared and delivered only for educational purposes and is not intended to infringe upon the copyrighted material. Sources have been acknowledged where applicable. The views expressed are presenter’s alone and do not necessarily represent actual author(s) or the institution. 4 Introduction Storage Structure I/O Structure I/O Communication Techniques Three techniques are possible for I/O operations: Programmed I/O Interrupt-driven I/O Direct Memory Access (DMA)
(From William Stallings Book)
Programmed I/O The I/O module performs the requested action, then sets the appropriate bits in the I/O status register. It is the responsibility of the processor to check the status of the I/O module periodically until it finds that the operation is complete. The processor is responsible for extracting data from main memory for output and storing data in main memory for input. The instruction set includes I/O instruction in the Control, Status and Transfer category. It is a time-consuming process that keeps the processor busy needlessly. (From William Stallings Book) (From William Stallings Book) Interrupt-Driven I/O It is better than programmed I/O because it eliminates needless waiting. The processor issue an I/O command to a module and then go on to do some other useful work. The I/O module will then interrupt the processor to request service when it is ready to exchange data with the processor. The processor then executes the data transfer, then resumes its former processing. It consumes a lot of processor time, because every word of data that goes from memory to I/O module or from I/O module to memory must pass through the processor. (From William Stallings Book) (From William Stallings Book) Direct Memory Access The DMA function can be performed by a separate module on the system bus or it can be incorporated into an I/O module. When the processor wishes to read or write a block of data, it issues a command to the I/O module, by sending the DMA module with the information: whether read or write is requested, the address of I/O device involved, the starting location in memory to read from or write to, the number of words to be read or written. The processor then continues with other work. It has delegated this I/O operation to the DMA module, which will take care of it, and thus processor is involve at the beginning and at the end of transfer. (From William Stallings Book) (From William Stallings Book) Cache Memory Cache memory is invisible to the operating system. It increase the speed of memory. The rate at which the processor can execute instructions is clearly limited by the memory cycle time. Over the years, the processor speed has consistently increased more rapidly than memory access speed. It is too expensive strategy if main memory is built with the same technology as that of processor. Cache is a small, fast memory between the processor and the main memory.
(From William Stallings Book)
(From William Stallings Book) Cache Principles It contains a copy of the portion of main memory. When the processor attempts to read a word of memory, a check is made to determine if the word is in cache, if so, word is delivered to the processor. If not, a block of main memory, consisting of fixed number of words, is read into the cache, and then delivered to the processor. It consists of C slots of K words, and the number of slots is considerably less than the number of main memory blocks.
(From William Stallings Book)
Cache Read Operation
(From William Stallings Book)
(From William Stallings Book) Cache Design Cache Size: Small caches have significant impact on performance. Block Size: Block size is the unit of data exchanged between cache and main memory. hit means the information was found in the cache As block size increases, more useful data is brought into the cache. larger block size more hits until probability of using newly fetched data becomes less than the probability of reusing data that has been moved out of cache
(From William Stallings Book)
Contd… Mapping Function Determines which cache location the block will occupy, when a new block of data is read into the cache. Two constraints affect the design of mapping function: replacement technique and the circuitry required to search the cache. Replacement Algorithm Chooses which block to replace when a new block is to be loaded into the cache and the cache has already slots filled with other blocks. Least Recently Used (LRU) algorithm
(From William Stallings Book)
Contd… Write Policy If the contents of the block in the cache are altered, then it is necessary to write Dictates when memory write operation takes place. Can occur every time block is updated Can occur only when block is replaced Minimizes memory operations Leaves memory in an obsolete state
(From William Stallings Book)
Computer System Architecture A computer-system can be categorize according to the number of general-purpose processors used. Single Processor System Multi Processor System Clustered Systems Single Processor System One main CPU capable of executing a general-purpose instructions set, including instruction from user processes Almost all systems have other special purpose processors as well, they run limited instruction set and do not run user processes Sometimes, managed by operating system, sends information about the next task and monitors their status Sometimes, special purpose processors are low level components built into the hardware, in that case operating system cannot communicate with these processors, they do their job autonomously. Multi-Processor Systems Two or more processors in close communication, sharing the computer bus and sometimes the clock, memory and peripheral devices. Also known as parallel systems or tightly coupled systems Advantages: Increased Throughput Economy of Scale Increased Reliability Graceful Degradation: The ability to continue providing service proportional to the level of surviving hardware. Fault Tolerant: Go beyond the graceful degradation. (detected, diagnose and if possible, corrected) Contd… Two types of multi processor system Asymmetric Multiprocessing Each processor is assigned a specific task A master/boss processor controls the system Master-slave/boss-worker relationship The master/boss processor schedules and allocate work to slave/worker processor Symmetric Multiprocessing Each processor performs all tasks within the operating system All processors are peers No master-slave relationship Advantage: many processors can run simultaneously Contd… A recent CPU design is to include multiple computer cores on a single chip These multi core CPU’s look to the operating system just as N standard processors Clustered System Cluster computers share storage and are closely linked via LAN networking. Clustering provides high reliability. In clustering, a layer of cluster software runs on the cluster nodes and each node can monitor one or more of the others over the LAN. If the monitored machine fails, the monitoring node can take ownership of its storage and restart the applications that were running on the failed machine after a brief interruption. Contd… In an asymmetric clustering, one machine is in hot standby mode while the other is running the applications. The hot standby host (server) does nothing but monitors the active server. If that server fails, the hot standby host becomes the active server. In symmetric clustering, all N hosts are running the applications and they are monitoring each other. Parallel clusters allow multiple hosts to access the same data on the shared storage. Oracle parallel server has been designed to run on parallel clusters and each machine has full access to all data in the database. Operating System Structure Multiprogramming needed for efficiency Single user cannot keep either CPU or I/O devices busy at all times Multiprogramming increase CPU utilization, organizes jobs (code and data) so CPU always has one to execute Job Pool: contain all the jobs that enter the system A subset of total jobs in system is kept in memory which is less than the total number of jobs in the job pool One job selected and run via job scheduling When it has to wait (for I/O for example), OS switches to another job When the job gets finishes waiting and gets the CPU back Contd… Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing Gives instructions to the operating system or to the user directly using keyboard or mouse Response time should be < 1 second Each user has at least one program executing in memory process Give the impression to the user, that system is entirely dedicated to his use If several jobs ready to run at the same time CPU scheduling Contd… Interactive I/O typically runs at “people speed”, it may take a long time to complete If processes don’t fit in memory, swapping moves them in and out to run Virtual memory allows execution of processes not completely in memory, enabling users to run programs that are larger than actual physical memory Operating System Operations Modern operating systems are interrupt driven Software error or request creates exception or trap Division by zero, invalid memory access, request for operating system service For each type of interrupt, separate segments of code in the operating system determine which action to take Other process problems include infinite loop, processes modifying each other or the operating system More subtle errors occur in multiprogramming, where one erroneous program might modify another program, the data of another program, or even the operating system itself Dual Mode Operation Need to distinguish between execution of user defined code and operating system code for the proper execution of operating system Dual-mode operation allows OS to protect itself and other system components User mode and kernel mode Mode bit provided by hardware Provides ability to distinguish when system is running user code or kernel code Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user At system boot time, the hardware starts in kernel mode. Contd… Hardware allows privileged instructions to be executed only in kernel mode System call provide the means for a user program to ask the operating system to perform tasks reserved for the operating system on the user program behalf Timer Timer to prevent infinite loop / process hogging resources (return control to operating system) Set interrupt after specific period Variable counter implement by fixed clock rate Operating system decrements counter When counter zero generate an interrupt Set up before scheduling process to regain control or terminate program that exceeds allotted time Process Management A process is a program in execution. It is a unit of work within the system. Program is a passive entity, process is an active entity. Process needs resources to accomplish its task CPU, memory, I/O, files Initialization data Resources given when process is first created, or allocated when it is running Process termination requires reclaim of any reusable resources Single-threaded process has one program counter specifying location of next instruction to execute Process executes instructions sequentially, one at a time, until completion Contd.. Multi-threaded process has one program counter per thread Typically system has many processes, some user, some operating system running concurrently on one or more CPUs The operating system is responsible for the following activities in connection with process management: Creating and deleting both user and system processes Suspending and resuming processes Providing mechanisms for process synchronization Providing mechanisms for process communication Providing mechanisms for deadlock handling Memory Management Main memory is the large array of words or bytes ranging in size Each word or byte has its own address All data in memory before and after processing All instructions in memory in order to execute Mapped into absolute addresses in order to execute After termination of process, memory space becomes available Memory management determines what is in memory when Optimizing CPU utilization and computer response to users Contd… Memory management activities Keeping track of which parts of memory are currently being used and by whom Deciding which processes (or parts thereof) and data to move into and out of memory Allocating and deallocating memory space as needed Storage Management Operating System provides uniform, logical view of information storage Abstracts physical properties to logical storage unit - file Maps file onto physical media and access these files via the storage devices File Management System Computer store information on the physical media. Each medium has its own characteristics and physical organization Each medium is controlled by a device that has its own unique properties Properties include access speed, capacity, data transfer rate, and access method (sequential or random) File are organized into directories Access control on most systems to determine who can access what OS activities include Creating and deleting files and directories Primitives to manipulate files and directories Mapping files onto secondary storage Backup files onto stable (non-volatile) storage media Mass Storage Management Usually disks used to store data that does not fit in main memory or data that must be kept for a “long” period of time. Proper management is of central importance Entire speed of computer operation hinges on disk subsystem and its algorithms OS activities Free-space management Storage allocation Disk scheduling
Some storage need not be fast
Tertiary storage includes optical storage, magnetic tape Still must be managed Varies between WORM (write-once, read-many-times) and RW (read- write) Caching Important principle of computer systems Information in use copied from slower to faster storage temporarily Faster storage (cache) checked first to determine if information is there If it is, information used directly from the cache (fast) If not, data copied to cache and used there Cache smaller than storage being cached Cache management important design problem Cache size and replacement policy Performance of Various Levels of Storage I/O Systems One purpose of OS is to hide peculiarities of hardware devices from the user I/O subsystem responsible for Memory management of I/O including buffering (storing data temporarily while it is being transferred), caching (storing parts of data in faster storage for performance), spooling (the overlapping of output of one job with input of other jobs) General device-driver interface Drivers for specific hardware devices Only the device driver knows the peculiarities of the specific device to which it is assigned Protection & Security When there are multiple users, and allow concurrent execution of multiple processes, then there is need to regulate the access of data There should be mechanism that ensures that files, memory segment, CPU and other resources can only be operated by only those processes that have gained proper authorization from the operating system Example: Memory addressing hardware Timer Contd…. Protection : any mechanism for controlling access of processes or users to resources defined by the OS. Improve reliability be detecting latent errors at the interface Adequate protection, still prone to failure Security :defense of the system against internal and external attacks Huge range, including denial-of-service (use all system resources), worms (malware computer program that replicates itself), viruses, identity theft, theft of service (unauthorized use of system) Contd…. For protection and security, systems generally first distinguish among users, to determine who can do what User identities (user IDs, security IDs) include name and associated number, one per user User ID then associated with all files, processes of that user to determine access control Group identifier (group ID) allows set of users to be defined and controls managed, then also associated with each process, file Privilege escalation allows user to change to effective ID with more rights Kernel Data Structures It tells the way the data are structured in the system Several fundamental data structures used extensively in operating system Lists, Stacks and Queues Trees Hash Functions and Maps Bitmaps Lists, Stacks and Queues An array is a simple data structure in which each element can be accessed directly For example, main memory is constructed as an array After arrays, lists are perhaps the most fundamental data structures in computer science Lists represent the collection of data values as a sequence Singly Linked List Doubly Linked List Circularly Linked List A stack is a sequentially ordered data structure that uses the LIFO principle for adding & removing items A queue is a sequentially ordered data structure that uses the FIFO principle for adding & removing items Trees A tree is a data structure that can be used to represent data hierarchically Data values in a tree structure are linked through parent- child relationships Hash Functions and Maps A hash function takes data as its input, performs a numeric operation on this data , and returns a numeric value This numeric value can then be used as an index into a table to quickly retrieve the data One potential difficulty with hash functions is that two inputs can result in the same output value, that is, they can link to the same table location Bitmaps A bitmap is a string of n binary digits that can be used to represent the status of n items For example, suppose we have several resources, and the availability of each resource is indicated by the value of binary digit 0 means that the resource is available 1 means that it is unavailable 001011101 The power of bitmaps becomes apparent when we consider their space efficiency A bitmap can be used to indicate the availability of each disk block Computing Environments Traditional Computing Mobile Computing Distributed Systems Client-Server Computing Peer-to-Peer Computing Virtualization Cloud Computing Real Time Embedded Systems Traditional Computing PCs, terminals, laptops etc attached to the network, portability achieved by the use of laptop Establishing portal, provide web accessibility to the internal servers They can also connect to the wireless network to use web portal Firewall is used to protect network from security breaches Mobile Computing Personal Digital Assistants (PDAs such as Palm-Pilots or cellular telephones) with connectivity to a network such as Internet. Small size, weigh less than one-half pound. Issues: Limited memory Slow processors Small display screens (web clipping is used to display the contents in web pages) Some handheld devices also use wireless technology (WAP) allowing remote access to e-mail and web browsing. Major benefits of handheld systems are convenience and portability. Distributed System A collection of physically separate, possibly heterogeneous computer systems, networked to provide user accesses to resources that system maintained Increased computation speed, functionality, data availability and reliability Network either through LAN, WAN, MAN Networks vary by the protocols used , the distances between the nodes and the transport media Termed as loosely-coupled systems because processors do not share memory or clock Such OS needs more advance features for scheduling and memory management Contd… Distributed processors may vary in size and function (small microprocessors, workstations, mini-computers and a large general-purpose computers) Processors/sites/nodes/computers communicate through high-speed communication lines such as high-speed buses, telephone line, satellites, microwave dishes, radios etc. May be either client-server or peer-to-peer systems Client-Server Computing One of the structure of distributed system Many of the today’s system act as server system to satisfy the requirement generated by the client system Server is bottleneck Categorization of Server system: Computer Server and File Server Compute Server System: provides the interface to which client can send request to perform an action. Example, server running a database File Server System: provides a file-system interface where client can create, update, read and delete files. Example: web server Client-Server Computing Peer to Peer Computing Another structure of distributed system All nodes within the system are considered peers Each may act as a client or server depend requesting a service or providing a service To participate in peer to peer system, a node first joined the network of peers, then node can request or provide services Two ways to search the desired service Centralized Lookup Service Broadcasting Peer to Peer Computing Virtualization Virtualization is a technology that allows operating system to run as applications within other operating system An operating system that is natively compiled for a particular CPU architecture runs with another operating system also native to that CPU Virtualization Cloud Computing Cloud computing is a type of computing that delivers computing, storage, and even applications as a service across a network It’s a logical extension of virtualization, because it uses virtualization as a base for its functionality Types of Cloud Computing Public Cloud Private Cloud Hybrid Cloud Software as a Service Platform as a Service Infrastructure as a Service Real-Time Embedded System Car engine, manufacturing robot to VCR and microwave oven Almost always run real time operating system, is used when rigid time requirements have been placed on the operation of processor or flow of data Sensors gathering information, computer analyzing it and adjusting appropriate controls to modify the sensor inputs. Open Source Operating Systems Open-source Operating Systems are those available in source code format rather than compiled binary code Starting with the source code allows the programmer to produce binary code that can be executed on the system Benefits include community of interested programmers who contribute to the code by helping to debug it, analyze it, provide support and suggest changes Reference Operating Systems, Latest Edition, William Stallings Book: Operating System Principles , 9th Edition , Abraham Silberschatz, Peter Baer Galvin, Greg Gagne