Document Details

SelfDeterminationSphinx

Uploaded by SelfDeterminationSphinx

Tags

operating systems computer science software engineering technology

Full Transcript

OPERATING SYSTEMS U18CA506 UNIT – I & II Introduction to Operating System Introduction to Operating System : What is an operating system? - Operating system (OS) is a program or set of programs, which acts as an interface between software & the computer har...

OPERATING SYSTEMS U18CA506 UNIT – I & II Introduction to Operating System Introduction to Operating System : What is an operating system? - Operating system (OS) is a program or set of programs, which acts as an interface between software & the computer hardware. - The main purpose of an OS is to provide an environment in which we can execute programs. - The main goals of the OS are (i) To make the computer system convenient to use (ii)To make the use of computer hardware in efficient way. - Operating System is system software. - which may be viewed as collection of software consisting of procedures for operating the computer & providing an environment for execution of programs. - It’s an interface between user & computer. - So an OS makes everything in the computer to work together smoothly & efficiently. - There are many important reasons for studying os: 1) to design your own os or modify an existing one. 2) selection of os 3) user interact with os - The Os act as an interface between the user program and the physical computer h/w Importance of Operating Systems: - Computers have become essential to society in such traditional applications as payroll and banking. - Computers are now being used in new fields such as * design of automobiles * improved medical care * space exploration - The operating system performs * the task of scheduling the use of computer * increase the efficiency * decrease the cost Basic concepts and Terminology (i) Computer Hardware structure terminology (ii) Programming terminology (iii) Operating System Terminology (i) Computer Hardware structure Terminology: - Many different computer h/w exists - They are * Memory * CPUs * I/O Processor * Control Units and Devices * Memory: Instructions and Data are stored in main storage called memory * CPU: - It is a h/w device capable of interpreting instructions and performing operations( Eg: Addition, Subtraction….). - A computer system has one or more CPU. -It is also named as processor * I/O Processor: - I/O Processors are designed to control I/O devices * Control Unit: - Many devices such as * card reader, printers, disks, drums and tapes etc…requires control circuitry. -This common h/w is sometimes separated out into a device called control unit (ii) Programming Terminology: - Software is the collection of programs that are used to perform some task. - A Program is a sequence of instructions - Programs are placed into main memory - executed by a processor - programs are stored in secondary storage device such as a disk, drum or tape - The operating system provides an environment in which particular program can be execute Eg: Compiler (iii) Operating System Terminology: - A user submit his job to operating system. - A Job is the collection of activities needed to do the work - A Job may be divided into several steps(Job Steps) - Job Steps are units of work that must be done sequentially. -once the os accepts a user’s job then it may create several process. Process: - It is a computation that may be done concurrently with other computations. -The following fig depicts the relationship between user,job,process and address spaces - The above fig shows two address spaces (i) I/O process (ii) CPU Process Multiprogramming: - A system may have several process at a same time. - Most computers have at least two states of execution * problem state(user state) * supervisor state(execution state) An Operating System Resource Manager: - The OS is a manager of system resources. - A computer system has many resources. - Since there can be many conflicting requests for the resources, the OS must decide which requests are to be allocated resources to operate the computer system fairly & efficiently. - The OS as a resources manager can be classified in to the following three popular views: * primary view * hierarchical view * extended machine view. - The primary view is that the OS is a collection of programs designed to manage the system’s resources, namely, *memory, processors, peripheral devices, & information. - It is the function of OS to see that they are used efficiently & to resolve conflicts arising from competition among the various users. - The OS must keep track of status of each resource; decide which process is to get the resource, allocate it, & eventually reclaim it. - The Operating system as a resource manager, each manager do the following 1. Keep track of the resources 2. Enforce policy to determine who gets what , when and how much 3. Allocate the Resource 4. Reallocate the Resource The major functions of each category of OS are. 1.Memory Management Functions -The OS is responsible for the following memory management functions: 1.Keep track of which segment of memory is in use & by whom. 2. Deciding which processes are to be loaded into memory when space becomes available. In multiprogramming environment it decides which process gets the available memory, when it gets it, where does it get it, & how. 3. Allocate or de-allocation the contents of memory when the process request for it otherwise reclaim the memory when the process does not require it or has been terminated. 2. Processor/Process Management Functions - A process is an instance of a program in execution. -The OS is responsible for the following processor/ process management functions: 1. Provides mechanisms for process synchronization for sharing of resources amongst concurrent processes. 2. Keeps track of processor & status of processes. The program that does this has been called the traffic controller. 3. Decide which process will have a chance to use the processor 4. Allocate the processor to a process. 5. Reallocate the resources. 3. I/O Device Management Functions -The OS is responsible for the following I/O Device Management Functions: 1.Keep track of the I/O devices, I/O channels, etc. This module is typically called I/O traffic controller. 2. Decide what is an efficient way to allocate the I/O resource. If it is to be shared, then decide who gets it, how much of it is to be allocated, & for how long. This is called I/O scheduling 3. Allocate the I/O device & initiate the I/O operation. 4. Reallocate the resource 4.Information Management Functions 1. Keeps track of the information, its location, its usage, status, etc. The module called a file system provides these facilities. 2.Decides who gets hold of information, enforce protection mechanism, & provides for information access mechanism, etc. 3.Allocate the information to a requesting process, e.g., open a file. 4.De-allocate the resource, e.g., close a file I/O Programming ,Interrupt Programming ,Machine Structure (I) I/O Programming: - There are 3 basic components of early computer system: (i) The CPU (ii) Main storage Unit(memory) (iii) I/O devices These components can be interconnected - The early systems also contains I/O instructions such as READ A CARD PUNCH A CARD PRINT A LINE - to operate I/O devices one at a time. - An ADD instruction may take one ms of CPU time and a READ CARD instruction 500 ms of CPU time. - The disparity in speeds between the I/O devices and the CPU motivated the development of I/O Processors(also called I/O Channels) I/O Channels: - It provide a path for the data to flow between I/O devices and the main memory. I/O Processors: - They are specialized processing units intended to operate the I/O devices. - They are much less expensive than a CPU. - The following fig. shows a computer system with a separate I/O channel for each device Types of I/O Channel: - I/O channels come in all shapes and sizes, ranging from very simple processors to highly complex CPUs. - It is costly to use one channel per device so it leads to development of selector and multiplexor channels. - multiple devices may be connected to each channel (up to 256 devices per channel). (i) Selector channel - A selector channel can service only one device at a time-i.e., one device is selected for service. - These channels are normally used for very high-speed I/O devices, such as magnetic tapes , disks and drums. - Each I/O request is completed quickly. (ii) Multiplexor Channel: - It simultaneously service many devices (up to 256). - It is used for slow I/O devices, such as card readers, card punches and printers. (iii) Block Multiplexor Channel: - It allows multiple channel programs for high-speed devices. - It performs one channel instruction for one device and then, automatically , switches to perform an instruction for another device, and so on. - A typical 370 configuration is given below (ii) I/O Programming Concepts: - The CPU communicates with the I/O processor to perform certain actions such as START I/O and HALT I/O. - The I/O processor communicate with the CPU by means of interrupts. - I/O processor interprets its own set of instructions. I/O Program: - The program contains set of I/O commands are known an I/O programs. - Programmers do not write their own I/o programs , but call system-supplied functions. (iii) I/O Processor Structure: * Memory * Register * Data * Instructions Register: -The I/O channel has no explicit register. - some I/O devices have internal registers Data: -Some I/O devices may include some types of code conversions on the data Eg: code conversions from EBCDIC to BCD Memory: - The basic memory unit is a byte and size is up to 2 24 bytes. - For addressing , the I/O channels uses a 24-bit absolute address.. Instructions: - There are three basic groupings of I/O commands. 1. Data Transfers: read; read backwards;write;sense 2. Device control: Control(page eject, tape rewind , etc) 3. Branching: transfers of control within the channel program - The Channel fetches the channel commands [Channel Command Words(CCW)] from memory and decodes them according to the following format. Opcode(bits 0-7): It indicates the command to be performed - it actually consists of two parts 2 to 4 - operation bits 4 to 6-- modifier bits Data Address(bits 8-31): - it specifies the beginning location of the data field. Count field: - it specifies the byte length of the data field. The flag bits further specialize the command. The principal flags are: (iv) Special Features of I/O programming: 1. Channel Address Word (CAW): contains the address of the first instruction to be executed 2. Channel Status Word(CSW): - it is a double word. - it contains coded information indicating the status of the channel 3. Channel Command Word(CCW): - fetches the channel commands from the memory and decides according to the format of the CSW. The format of CSW (v) Communication between the CPU and the Channel: - The CPU and the Channel are usually in a Master/Slave relationship. - This means that the CPU tells the channel when to start and commands it to stop. - The channel cannot usually start only operations unless instructed by the CPU. -There are 2 types of communications between the CPU and the Channel. i) CPU to Channel : I/O instructions initiated by the CPU. ii) Channel to CPU: interrupt initiated by the channel. - All CPU I/O instructions has the following format B1 – The Channel numbers D1 – The Device numbers - Bits 16-23 of the sum contain the channel address, - while bits 24-31 contain the device on the channel - we are mainly concerned with 3 CPU I/O instructions. They are * START I/O * TEST I/O * HALT I/O * START I/O(SIO): - Two items are needed to start I/O: (i) The Channel and Device number (ii) The beginning address of the channel program Eg: SIO X00E-specifies channel number 0 and device number OE * TEST I/O (TIO): * HALT I/O(HIO): - After executing an SIO or a TIO the CPU gets a condition code of either: 8 -- ok(not busy) 2 -- busy 1 – not operational 4 – indicates that instruction is just stored and going to be processed - The channel status word(CSW) provides the detailed status of an I/O device. - The format of CSW is (vi) I/O Example using Single Buffering: - We wish to read and print a series of cards. - One simple strategy is illustrated in the following fig: - This sample program does not take advantage of the I/O channels. - whenever the CPU is running, the channels are idle, and whenever a channel is running , the CPU is idle and waiting for the channel to finish. (vii) I/O Example using double buffering: - To increase the number of cards processed for minutes using double buffering technique. - With double buffering , we first read a card into buffer area 1;then , while printing out this area, we read the next card into buffer area 2;when we are finished printing buffer area1, we then can start reading into buffer area 1 and repeat this process (viii) Multiple card Buffering: - This buffering is useful when we read more than one cards. - This technique supports maximum 60 cards for reading and printing at a time. Interrupt Structure and Processing: - An interrupt is (1) a response to an asynchronous or exceptional event (2) automatically saves the current CPU status to allow later restart (3) causes an automatic transfer to a specified routine (called an interrupt handler) - The following fig. Depicts the execution path of an interrupted processor Interrupt Types: - The various types of interrupts are divided into 5 classes: Interrupt Mechanism: - The state or current condition of the CPU is stored in a double word register called the Program Status Word(PSW). - This correspond to the CSW of the I/O processor. - The PSW is used to control instruction sequencing and to hold and indicate the status of the system in relation to the program currently being executed. - The active PSW is the current PSW. - By storing the PSW during an interruption, the status of the CPU can be preserved for inspection or reloading. - The Format of the PSW is as follows - Bits in the PSW may be used to mask certain interruptions. - The programmer has various status switching instructions. These include * Load PSW [LPSW] * Set Program Mask [SPM] * Set System Mask [SSM] * supervisor Call [SVC] * Set Storage Key [SSK] - Most of these are privileged instructions and can be executed only in supervisor mode. - Five classes of interrupts 1. I/O 2. Program 3. Supervisor Call 4. External 5. Machine-check Unit - II Memory Management Single contiguous memory management Paged Memory Management Demand Paged Memory Management Segmented Memory Management Segmented and Demand Paged Memory Management Other Memory Managements Memory Management: - It is one of the module of an Operating system. - It is concerned with the management of primary memory - The processor directly access the instruction and data from main memory. Four Functions of Memory Management: 1.Keep track of which segment of memory is in use & by whom. 2. Deciding which processes are to be loaded into memory when space becomes available. In multiprogramming environment it decides which process gets the available memory, when it gets it, where does it get it, & how. 3. Allocate the memory 4.De-allocate the memory when the process terminated. Memory Management Techniques: 1. Single Contiguous Memory Management 2. Partitioned Memory Management 3. Relocation Memory Management 4. Paged Memory Management 5. Demand-paged Memory Management 6. Segmented Memory Management 7. Segmented and Demand-Paged Memory Management 8. Other Memory Management - Swapping - Overlays Contiguous Storage Allocation: - Each program had to occupy a single contiguous block of location. Non-contiguous storage Allocation: - A program is divided into several blocks or segments - These blocks (or) segments may be placed throughout main storage. - not necessarily adjacent to each other. 1. Single Contiguous Allocation: - It is a simple memory management scheme - The main memory is usually divided into two partitions * A portion of memory is permanently allocated to the os * Another one for the user process. - It requires no special h/w - There is no multiprogramming Memory - The Job uses only a porting of the allocated memory. OS User Area Example: Memory Size = 256 k Bytes OS require = 32 k bytes User Area = 224 k bytes (1 kb=1024 bytes) 0 0 31 31 255 Boundary Register: - It contain highest address used by os. - During the execution of a program , the memory protection hardware compute every address used in the program with the content of register. 0 Bound OS Register CPU a JOB a b Free c Area -if the user tries to enter the os, the instruction is intercepted and job terminates with an appropriate error message. (i) Memory Management Functions for Single Contiguous Allocation: 1. keep track of memory 2. determining the policy 3. allocating of memory 4. deallocation of memory (ii) Hardware Support: - no special h/w is required for single contiguous allocation. (iii) Protection through Bound Register: - we need to protect the os code and data from changes made by user processes. - It can be done by using single boundary register built into the CPU. Memory production violation interrupt -This interrupts is generated if an address lies outside the allocated area. - On sensing this interrupts the os can terminate the erroring job. Bound Example: Register CPU 0 32767 32767 32768 User Load 1,32761 job Protection violation interrupt is generated Free Area 255 k Reason: 32761 is os area (iii) A flow chart of a single contiguous Allocation: (iv) Advantages – Easy to understand – Very Simple – OS require little amount of memory (v) Disadvantages – Poor utilization of memory – Poor utilization of CPU [waiting for I/O] – Job size is limited Memory Management Functions for Partitioned Allocation 2.2 Partitioned Allocation -Main memory is divided into separate memory register or memory partitions. - Each partition holds a separate job -It supporting “ Multiprogramming” Memory Management Functions for Partitioned Allocation 1. Keeping track of the status of each partition [Eg: “in use” or “not in use”, size] 2. Determining who gets memory 3. Allocation an available partition of sufficient size is assigned. 4. De-allocation when the job terminates the partition is indicated “not in use”. OS Partition 1 JOB1 Partition 1 JOB2 Partition 1 JOB3 Types of partition 1. Static or Fixed partition specification 2. Dynamic or variable partition specification 1. Static or Fixed partition specification – The memory is divided into partitions prior to the processing of any jobs. – It is similar to multiprogramming with fixed number of tasks – The degree of multiprogramming based on number of partition. (a) Fixed partitioning with equal size (b) Fixed partitioning with variable size (a)Fixed partitioning with equal size – Memory is divided into fixed number of partitions with equal size. – In this case, any process whose size is less than or equal to partitioned size can be loaded into memory. OS OS 150 kb 150 kb 150 kb 150 kb 150 kb 750 kb is divided into five regions with equal size (b) Fixed Partitioning with variable size: - the memory is divided into Fixed number of partitions with unequal size. OS 250 kb 155 kb 750 kb is divided into five regions 125 kb with unequal size 95 kb 75 kb (iii) Advantages – Multiprogramming – Efficient CPU utilization (iv) Disadvantages – If there is a job whose memory requirement is more than that of any partition, then the job cannot be run ie. Job size

Use Quizgecko on...
Browser
Browser