1 / 39

9691 Computing

9691 Computing. Paper 3 Section 3.1 The functions of Operating Systems. Functions of Operating Systems (OS). All Operating Systems (OS) have three main functions: Controlling and Managing Hardware Providing An Interface (Human-Machine and Machine-Software)

lester
Download Presentation

9691 Computing

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. 9691 Computing Paper 3 Section 3.1 The functions of Operating Systems

  2. Functions of Operating Systems (OS) • All Operating Systems (OS) have three main functions: • Controlling and Managing Hardware • Providing An Interface (Human-Machine and Machine-Software) • Facilitating Application Software To Run • Operating systems must: • Provide and manage hardware resources • Provide an interface between the user and the machine • Provide an interface between application software and the machine • Provide security for data on the system • Provide utility software to allow maintenance to be done VCN ICT Department 2013

  3. Features of OS • User interface: the two main types of user interfaces are command line and graphical user interface. • Device drivers (Routines which control hardware). Example: Keyboard driver • Multitasking capabilitywhich enables the computer to run more than one program at one time. (Example: Running a word processing program, spreadsheet program and a database program at the same time in the computer.) • Spooling: directs jobs and data files to a queue on a backing store before sending them to their intended peripheral device. VCN ICT Department 2013

  4. Features of OS (continued) • Security: ensures that users can keep their files confidential • Scheduler: allocates job priorities and find and resolve deadlocks using scheduling algorithms • Memory manager: allocates memory to jobs and data • Interrupt handler: routine in the operating system which puts interrupts in a queue until they are processed by the processor. • Translators: converts source code of application programs into object code or to machine code VCN ICT Department 2013

  5. Interrupts • An interruptis a signal from a hardware device or an instruction from a software program indicating the processor the need for a change in execution. • The processor processes program instructions stored in the memory. It fetches instructions one after the other and executes them. • If a problem occurs (anywhere in the system) while the processor is busy processing, the processor must respond to the problem as soon as possible in order to avoid damage to data and/or hardware. • This requires the processor to stop whatever it is doing and give its attention to the problem. • The device (hardware) or software, where the problem has occurred generates a signal, called an “interrupt” to get processor’s attention. This is a simple method a computer uses to carry out instructions. VCN ICT Department 2013

  6. Types of Interrupt • I/O interrupt • Generated by an I/O device to signal that a job is complete or an error has occurred. • E.g. • Printer is out of paper or is not connected. • Timer interrupt • Generated at fixed intervals. • Allows for display refresh and to control access to processor in multi-access or multi-programming system.

  7. Types of Interrupt • Hardware interrupt • E.g. • Power failure which indicates that the OS must close down as safely as possible. • Program interrupt • Generated due to an error in a program such as violation of memory use (trying to use part of the memory reserved by the OS for other use) or an attempt to execute an invalid instruction (such as division by zero).

  8. Types of Interrupts (Summary) • Hardware: Generated by hardware devices. (Hardware failure. Hardware going off-line) • Software: Generated by software applications. (Violation of memory space. Virus found, division by zero) • Timer: Generated by internal clock. (Scheduling of processes; an event is due) • I/O: Generated by an I/O device. (e.g Printer out of paper; CD copying completed) VCN ICT Department 2013

  9. Managing interrupts • After execution of an instruction, the processor must see if an interrupt has occurred. • If yes, the OS services that interrupt following a new set of instructions. VCN ICT Department 2013

  10. What happens if the current job is more important than the interrupt? • The Priority of the interrupt is compared with current job. • If higher: • An appropriate interrupt service routine (ISR), depending on the interrupt's importance, is loaded and run. • The Interrupt is serviced by the processor. • If lower: • The interrupt is placed in a queue. • The current job continues with next cycle. VCN ICT Department 2013

  11. Resuming an interrupted program from where it left off after interrupt has been Serviced • The state of the current job is saved. • This is done by saving the contents of all the registers in the processor so that the OS can use them to service the interrupt. • The OS can load the register contents back in the registers to resume the job being interrupted once the interrupt has been serviced VCN ICT Department 2013

  12. What happens if several interrupts occur at the same time? • Place the interrupts in a queue and only allow return to the originally interrupted program when the queue is empty. • However, if an interrupt is considered important enough then an interrupt service routine (ISR) is chosen, which will “mask” the interrupt, meaning that any future interrupts are not considered until the current interrupt is completed. VCN ICT Department 2013

  13. What happens if some interrupts are more important than others? • The Interrupt is allocated a position in the job queue according to priorities. • How this priority is decided is called scheduling VCN ICT Department 2013

  14. Handling Interrupts - Summary • The Current cycle is completed • Then the priority of interrupt is compared with the current job • If higher: • Contents of special registers are saved, the current job is allocated a position in the job queue according to priorities • Interrupt is serviced by OS. • On completion, values of special registers from original program are loaded and the original job is restored. • If lower: • Interrupt is allocated a position in the job queue according to priorities. • Current job continues with next cycle.

  15. JOB SCHEDULING • Scheduling is an OS process that starts and ends tasks (programs), manages concurrently running processes, and allocates system resources. REASONS FOR SCHEDULING • Maximize the use of the whole of the computer system • Be fair to all users • Provide a reasonable response time to all users, whether they are on-line users or a batch processing user • Prevent the system failing if it is becoming overloaded • Make sure that the system is consistent by always giving similar response times to similar activities from day to day VCN ICT Department 2013

  16. Input Output (I/O) bound Vs Processor bound jobs • I/O bound jobs are those that require relatively little processing but do need to use the peripheral devices substantially. • E.g. Printing wage slips for the employees of a large company • Processor bound jobs are those that require a large amount of processor time and very little use of the various peripheral devices. • E.g. Analysing the annual, world-wide sales of the company which has a turnover of many billions of Shillings. VCN ICT Department 2013

  17. Scheduling Example Job A is processor-bound and Job B is I/O bound. I/O bound jobs are given more time in order to allow them to finish in reasonable time. Processor bound jobs are given lesser time as they can do more in less time and shouldn’t hold the I/O bound jobs. VCN ICT Department 2013

  18. STRATEGIES FOR SCHEDULING • Scheduling of processes requires careful considerations. The following are the most common: • Priority: Giving some jobs priority over others. • I/O or Processor Bound: Deciding which job is processor bound and which is I/O bound. • Type of Job: Batch processing, on-line and real-time jobs all require different response times. • Resource Requirements: The amount of time needed to complete the job, the memory required, I/O and processor time. • Resources Used So Far: The amount of processor time used so far, how much I/O used so far. • Waiting Time: The time the job has been waiting to use the system. VCN ICT Department 2013

  19. Process handling • A job can be in any of the following states. • Ready [Ready to start] • Running [on the system] • Blocked [Waiting for a peripheral] • A job can only enter the running state from the ready state. • The ready and blocked states are queues that may hold several jobs. • On a standard single processor computer only one job can be in the running state. • All jobs entering the system normally enter via the ready state and (normally) only leave the system from the running state. NOTE VCN ICT Department 2013

  20. Schedulers • High Level Scheduler (HLS) is responsible for placing a job in the ready queue. The HLS makes sure that the system is not over loaded. • Mid-Level Scheduler (MLS) is responsible for swapping jobs between main and secondary memory. • Low-Level Scheduler (LLS) is responsible for Moving jobs in and out of the ready state. • The LLS decides the order in which jobs are to be placed in the running state. VCN ICT Department 2013

  21. Scheduling policies • There are many policies that may be used to do scheduling, but they can all be placed in one of two classes. These are pre-emptive and non-pre-emptive policies. • Pre-emptive policy: allows the LLS to put or remove jobs from the RUNNING queue as and when needed. • Non Pre-emptive policy allows jobs to run until they no longer need the processor. VCN ICT Department 2013

  22. Common scheduling algorithms • First come first Served (FCFS): Simply means that the first job to enter the ready queue is the first to enter the running state. This favors long jobs. (Non pre-emptive by design) • Shortest Job first (SJF): Simply means sort jobs in the ready queue in ascending order of times expected to be needed by each job. New jobs are added to the queue in such a way as to preserve this order. (Non pre-emptive) • Round Robin (RR): This gives each job a maximum length of processor time (called a time slice) after which the job is put at the back of the ready queue and the job at the front of the queue is given use of the processor. If a job is completed before the maximum time is up it leaves the system. • Shortest Remaining Time (SRT): The ready queue is sorted on the amount of expected time still required by a job. This scheme favours short jobs even more than SJF. Also there is a danger of long jobs being prevented from running. • Priority Queues (PQ): Priority Queues involve queues of different priorities. Jobs in higher priority queues are executed first. • Multi-level Feedback queues (MFQ): Involves several queues of different priorities with jobs migrating downwards. VCN ICT Department 2013

  23. Other methods of allocating priorities: All the policies discussed on previous slides are methods of allocating priorities. Here are some others: • Amount of time already waited. • Amount of processor time already given. • Amount of peripheral time. • Compares I/O jobs and asks “How much of a I/O job are you?” • Necessary response time. • Compares real-time / on-line jobs and asks “How much of a real-time / on-line jobs are you?” or “OK, you are a real-time / on-line job but how quickly do I need to respond to you?”

  24. Other methods of allocating priorities: • Importance of Job / Type of Job • Safety critical jobs will be given very high priority, on-line and real time applications will also have to have high priorities. • E.g. • A computer monitoring the temperature and pressure in a chemical process whilst analysing results of readings taken over a period of time must give the high priority to the control program. • If the temperature or pressure goes out of a pre-defined range, the control program must take over immediately. • A bank's computer is printing bank statements over night and someone wishes to use a cash point, the cash point job must take priority. • Also remember I/O bound jobs will also get priority as stated earlier. • Can be Pre-Emptive or Non-Pre-Emptive depending on if the queue is checked after each cycle or not. VCN ICT Department 2013

  25. Memory Management • Memory Management is the process of managing jobs and their data in the memory. • When a job needs to be processed, it is stored in the main memory along with its data. • In most of the modern OS, more than one job can be loaded into the memory at one time. • If several job are stored in the memory, their data must be protected from the actions of other jobs. VCN ICT Department 2013

  26. Memory Mgt Scenario • Suppose that jobs A, B, C and D have been loaded in RAM by the Mid level scheduler. • Now, imagine that the job with the next highest Priority is Job E and that is of Size 35Kb. It will wait because there’s only 20Kb free. • So the current jobs will run until one of them is completed. • If it is job D, no problem because we shall have enough space to run E. • If it’s job A, still no problem because the space is enough. • If it’s Job B, there’s a problem because the free gaps are not enough, so • we have to wait till there’s more free space. (Causing delays) • Part of job E is put in the free space and the rest where B used to be. (This causes fragmentation issues) • An active job can be moved to another location creating adjacent free space which is then used for the job (Makes heavy use of the processor) VCN ICT Department 2013

  27. Virtual memory • Virtual memory is the area on the disk that is used to store the pages of jobs of currently running programs and data temporarily, which makes it look like that the computer, has more memory than it actually has. • Virtual memory is necessary to: • allow programs to run that need more memory than is available; • allow multiple programs to run which have combined memory requirements more than the main memory available. • Virtual memory will, in some way, split a program into blocks and load the blocks that are needed, when they are needed – constantly swapping blocks between main memory and the backing store. • The switching between the virtual memory and main memory which involves the disk continuously searching for pages is called disk thrashing. • The two normal methods of splitting the programs into blocks are segmentation and paging. VCN ICT Department 2013

  28. Paging • In the paging memory-management scheme, the data transferred between virtual memory and physical memory is split into equally sized blocks called pages. • An index keeps track of what is in each page. • Pages in virtual memory that are not being executed are stored on disk in a page file. • A large job can span 2 or more pages. VCN ICT Department 2013

  29. Segmentation • Segmentation avoids the possibility of splitting up code halfway through because pages are not big enough. • Segments are adjustable size blocks. I.e. the size of a segment is not fixed whereas the size of a page is. • A segment will hold an entire section of code, relying on logical breaks in the code. • Space is not wasted as it would be in a page if the page size was bigger than the data going into it and the code is not split as it would be if it was bigger than the page size. • Segments are also indexed to keep track of what is in each page. VCN ICT Department 2013

  30. Spooling • SPOOL (Simultaneous Peripheral Output On Line) • It is a method used to place input and output on a fast access storage device, such as a disk, so that slow peripheral devices do not hold up the processor. • It allows for queues when several jobs want to use peripheral devices at the same time • It stops different input and outputs becoming mixed up VCN ICT Department 2013

  31. Spooling (Cont’d) Example • If two or more jobs are sent to a printer at the same time, the jobs are sent to a spool queue where they wait for the printer to be free. • The spool queue only stores reference to where the jobs are stored on a hard drive. • Spooling saves the user waiting for the printer (or other slow device) and allows the processor to do something else while the printing (or other slow process) finishes. • (An interrupt would be sent to request the next job from the spool queue.) Benefits of spooling • avoids delays – printers are relatively slow and so spooling frees up the processor quickly and allows it to get on with other jobs; • Allows more than one print job to be submitted at a time – each job will be held in a queue and printed one at a time – the use of a queue also allows priorities to be set. • in a multi-user system, provides a method of keeping print-jobs separate – it means that printouts will not be muddled up. • Lets the processor get on with something else while the jobs are queued VCN ICT Department 2013

  32. Modern Operating Systems • There are two main types of OS: • command line • graphical user interface (GUI). • Modern operating systems allow apparent multi-tasking by switching between multiple tasks very quickly. • Each application gets a time-slice. • When their processor time is up, and interrupt occurs and control is passed to the next application. • If a program requests use of a hardware device, the request is placed in a queue until the device is available. VCN ICT Department 2013

  33. Booting process • When the computer is first turned on, the CPU initializes itself. • Part of this initialization is to look for the BIOS (Basic input/output system). • Some of the BIOS is stored in ROM (read only memory) but since it is user-configurable, it is not completely stored in ROM, these parts are stored in CMOS RAM. • CMOS (complementary metal-oxide semiconductor) is a type of memory chip with very low power requirements which uses a small battery to retain data when the PC is turned off. • The BIOS cannot be stored on the hard disk because it contains the code to initialize such secondary storage devices. • The BIOS will then run its power-on-self-test (POST). VCN ICT Department 2013

  34. Booting process Power-on-self-test (POST) • The computer runs the power-on-self-test (POST) routine that is stored in ROM. The POST routine: • Checks the BIOS chip and tests the CMOS RAM • Verifies and clears CPU registers • Checks hardware devices e.g. video card, secondary storage devices, keyboard, mouse • Loads the address of the first instruction of the boot program into the program counter (PC). Boot Program • The boot program (also known as the boot loader or the bootstrap ) is stored in the ROM. It looks for an OS to load. • On a typical PC, the OS will be loaded from the C drive but it will check the floppy drive and CD drive beforehand. The order in which devices are checked for an OS is called the boot sequence and can be configured in the CMOS setup. • Once an OS has been located, the boot program will encounter the boot record, which tells it where to find the beginning of the OS and the subsequent program that will initialize the OS. VCN ICT Department 2013

  35. Booting process (Cont’d) OS Initialization • Once the program that initializes the OS is loaded, the BIOS copies its files into memory and the OS can take control over the rest of the boot process. • The OS performs another check of the memory and loads the device drivers needed by peripherals such as printers, scanners, mice and keyboards. VCN ICT Department 2013

  36. File Allocation Table (FAT) • The OS must be able to store and locate files on a disk. It uses a File Allocation Table (FAT) to do this. • The FAT uses a linked list to point to the blocks on the disk that contain files. • To do this, the OS formats the disk by dividing it into sectors and concentric circles (called tracks). • Two or more sectors on a single track make up a cluster. The FAT is loaded into RAM to speed up the search time and to avoid continual disk access. VCN ICT Department 2013

  37. File Allocation Tables (Cont’d) • This is an example of a file allocation table. • Every cluster on the disk is listed. If the cluster is empty, it has a zero entry. • Otherwise, the cluster containing the beginning of a file is labeled (with a pointer) and links to the cluster containing the next part of the file. • The cluster containing the end of the file has a null pointer. We can see that cluster 1 is empty. Our first example file 1 begins in cluster 2, the next part is in cluster 3 and the final part of the file is in cluster 5. File 2 begins in cluster 4, followed by cluster 6 with the remaining bits of the file in cluster 7. VCN ICT Department 2013

  38. File Allocation Tables (Cont’d) • The fragmentation of files is caused by deleting files. • Note that a file is never deleted from the physical disk, only the reference to it is removed from the FAT. Of course, when the disk is full it will be overwritten. • To find a file, • the OS looks in the table for the filename and, if it finds it, gets the cluster number for the start of the file. The OS can then follow the pointers in the table to find the rest of the file. • To delete a file, • it just has to set the clusters it occupied to zero. • To add a new file, • the OS has to linearly search for clusters with zero entries to set up the linked list. VCN ICT Department 2013

  39. Visit this link for more info • http://w2.compu2learn.co.uk/theory/advanced-theory/331-the-function-of-operating-systems/memory-management END. VCN ICT Department 2013

More Related