1 / 26

Understanding Operating System Functions: Memory Management

Learn the various functions of an Operating System, including memory management, CPU control, peripheral device management, and exam techniques. Explore how an OS handles memory, executes interrupts, manages devices, and more.

imorales
Download Presentation

Understanding Operating System Functions: Memory Management

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 2 The Functions of Operating Systems

  2. Starter Activity On Whiteboards… “List the main functions of an Operating System”

  3. Learning Habits Which ‘Learning Habits’ we will need to make use of to be a success in this lesson? Adapting: Reflecting and making changes Noticing details Reasoning: Thinking rigorously, methodically and giving explanations. Empathising… …with feelings and views Effective use of time Questioning: Asking questions to get below the surface Imagining… …how things could be and seeing a range of possibilities Listening… …to understand Distilling… …what you have learnt and what you need to learn Collaboration: Working effectively with others Meta Learning: Talking about how you have been learning Imitation: Picking up good habits from others Independence: Working effectively alone Managing distractions… …and sustaining concentration Capitalising: Using resources purposefully Perseverance: Overcoming frustration and difficulty Planning… …your learning in advance

  4. Lesson Objectives Lesson Objectives To understand the various functions of an Operation System To understand how an OS controls the working of the CPU to enable it to multi-task To understand how an OS manages memory To understand how an OS controls peripheral devices To understand some simple exam techniques: what the examiners want from your answers depending on the question’s key words and marks. Success Criteria ALL: To understand the main functions of an OS. MOST: To be able to apply that knowledge with success to exam questions surrounding Operating Systems and their function. SOME: To be able to question the various methods used by an OS in terms of their relative impact on their efficiency of a computer system.

  5. Functions of an Operating Systems Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Functions of an Operating System As mentioned in a previous lesson presentation, there are a number of functions that all operating system, regardless of their ‘type’, will perform. The following is a formalised list of the main functions of an operating system: • Interface • Memory Management (paging, segmentation and virtual memory) • Peripheral Management (Device Drivers) • Multi-Tasking (interrupts, the interrupt service routine and scheduling) We will now look at each of these functions in more detail.

  6. Memory Management(paging, segmentation and virtual memory) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. 1 2 3 Free Free 2 3 Free + ? 4 4 2 3 4 Free Memory Management One of the jobs of the OS is to manage the system’s memory. As each program is opened by the user, it is loaded onto the RAM and an important role of the OS is to ensure that no two programs can access each other’s data as this could allow for malicious data attacks. Another role is to ensure that the free space on RAM is being used efficiently. For example, if 3 programs of different sizes were loaded onto the RAM… …and 1 closed… …and another opened (4)… …it’s the OS’s job to ensure that the program can be loaded onto the RAM, even if there are no contiguous spaces available.

  7. Memory Management(paging, segmentation and virtual memory) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Paging and Segmentation There are two different methods that operating systems use to split programs up so that the RAM can be utilised efficiently. Paging Paging is where the operating system will split a program up into small, equally sized blocks of data (called pages, a few kb in size), which can then be assigned to non-contiguous memory locations in the RAM. This system requires a paging table, which is a record of where the different ‘pages’ (blocks of data) have been stored, so that the necessary data can be accessed when needed. Segmentation Segmentation is similar to the above but instead of a program being split into equally sized data blocks, the program is split logically, i.e. into modules or functions.

  8. Command Words – Higher Order Questioning E C-D A-B State/Identify/Give/Name Simply label a diagram, fill out a table or write a few words Describe Describing is ‘saying what you see’ E.G.: A computer will have a CPU, Primary and Secondary storage etc Explain / Why Explaining is ‘saying why something is like that’ E.G.: A computer will have a CPU so that it can process all of the data the computer needs to perform a range of tasks. Primary and Secondary storage is needed because… Discuss Discussing is ‘looking at two sides of an issue, weighing up the two views and giving a conclusion’. Often these require a mini essay answer. E.G.: New technology could be seen as being bad for the environment because…, but on the other hand, new technology has lead to… In conclusion I believe that… Describe/Explain/Discussusing examples Finally, if you are asked to give examples in any of these types of questions – YOU MUST GIVE EXAMPLES!

  9. Task Consider your target grade Pick one of the two exam questions Grade D-E target – pick either question Grade A-C target – pick the 7 marker Write your answer – 8mins

  10. Memory Management - Exam Practice E-D Question: A-C Question: “Explain the main difference between paging and segmentation” (3 marks) “Discuss the differences between paging and segmentation in terms of their efficient use of memory.” (7 marks)

  11. Assessment Criteria E-D GRADE STYLE QUESTION “Explain the main difference between paging and segmentation” (3 marks) Both paging and segmentation are methods used by the OS to management the memory (programs open and using the RAM) (1 mark) Paging splits the program’s data into set sized data blocks as its loaded onto the RAM(1 mark) Segmentation splits the program’s data into logically sized data blocks (splits the program by as its functions/modules) as its loaded onto the RAM (1 mark) A-C GRADE STYLE QUESTION “Discuss the differences between paging and segmentation in terms of their efficient use of memory.” (7 marks) Both paging and segmentation are methods used by the OS to management the memory (programs open and using the RAM) (1 mark) Paging splits the program’s data into set sized data blocks as its loaded onto the RAM(1 mark) This can improve efficiency in a computer system as a program’s data can be stored in all available spaces in the RAM, even if they are not together (non-contiguous) (1 mark)…but this can increase reading times as the data is not stored together (1 mark) Segmentation splits the program’s data into logically sized data blocks (splits the program by as its functions/modules) as its loaded onto the RAM (1 mark) This can improve efficiency in a computer system as a program’s data can be read as logical blocks of code (1 mark)…but if the RAM is quite full, it can be difficult to load the programs data into available spaces (1mark).

  12. Levels of Questioning E-D GRADE STYLE QUESTION “Explain the main difference between paging and segmentation” (3 marks) A-C GRADE STYLE QUESTION “Discuss the differences between paging and segmentation in terms of their efficient use of memory.” (7 marks) What makes these questions differ in terms of the ‘GRADE’ that they are aimed at?

  13. Command Words – Higher Order Questioning E C-D A-B State/Identify/Give/Name Simply label a diagram, fill out a table or write a few words Describe Describing is ‘saying what you see’ E.G.: A computer will have a CPU, Primary and Secondary storage etc Explain / Why Explaining is ‘saying why something is like that’ E.G.: A computer will have a CPU so that it can process all of the data the computer needs to perform a range of tasks. Primary and Secondary storage is needed because… Discuss Discussing is ‘looking at two sides of an issue, weighing up the two views and giving a conclusion’. Often these require a mini essay answer. E.G.: New technology could be seen as being bad for the environment because…, but on the other hand, new technology has lead to… In conclusion I believe that… Describe/Explain/Discussusing examples Finally, if you are asked to give examples in any of these types of questions – YOU MUST GIVE EXAMPLES!

  14. Task Pick a partner who did the same question Mark their work and provide critical feedback (by replying to their answer) based on the following assessment criteria.

  15. Memory Management(paging, segmentation and virtual memory) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Virtual Memory Sometimes, no matter how well the OS has used paging or segmentation to manage the free space in memory, the RAM can get used up. Another role of the operating system is to manage this situation. It does this by making use of something called virtual memory. Virtual memory is where secondary storage (usually the hard disk) is used as RAM. Programs that haven’t been used (but are still open) are moved to virtual memory, freeing up space in the RAM, so that new programs can be opened. The issue with virtual memory is that secondary storage devices are far slower at communicating with the CPU, so the user sees a notable dip in performance, when using programs in virtual memory.

  16. Multi-Tasking(scheduling, interrupts and the interrupt service routine ) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Interrupts / Interrupt Service Routine The CPU is an excellent multi-tasker. It can carryout the processes of several programs in quick succession resulting in the appearance of processing simultaneously. However, there are times when the CPU will have to momentarily stop processing instructions for running programs and deal with new requests (for example, an input signal from the user). These requests are known as interrupts – the CPU is interrupted and needs to deal with a request before continuing with its processing of running programs. When an interrupt is received, the CPU will carry out an Interrupt Service Routine (ISR). The ISR will evaluate how important the interrupt is and will either add it to a process queue (low importance interrupt) to be dealt with later or be handed to the CPU for immediate processing (interrupt with high importance).

  17. Multi-Tasking(scheduling, interrupts and the interrupt service routine ) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Multi-Tasking When multiple programs are running on a system, it is the job of an operating system to ensure that all programs are able to run simultaneously. The operating system does this by managing the processes that are given to the CPU. Operating systems attempt to ‘fairly’ share out the jobs required by several programs, using something called a ‘scheduler’. A scheduler uses an algorithm to work out how to share out the processor amongst the different programs. There are several different scheduling algorithms: • Round Robin • First Come, First Serve • Multi-Level Feedback Queue • Shortest Job First • Shortest Remaining Time

  18. Multi-Tasking(scheduling, interrupts and the interrupt service routine ) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Scheduling Algorithms Round Robin A ‘Round Robin’ scheduling algorithm is very simple in the way it works. It gives each process an equal, set amount of time to complete. If it fails to complete, it goes to the back of the queue making way for the next process. First Come, First Serve This scheduling algorithm does as the name suggests. The first process to request the services of the CPU is served, then the next process and the next etc. All processes are queued up in the order they arrive and dealt with according to their position.

  19. Multi-Tasking(scheduling, interrupts and the interrupt service routine ) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Scheduling Algorithms Shortest Job First Unsurprisingly, this algorithm will prioritise the jobs which can be executed the quickest, but clearly knowledge of the execution time of queued jobs needs to be calculated. Imagine you are wanting to carry out some maintenance jobs on your computer. You might want to move files into folders, delete unwanted documents, uninstall unused programs before running a disk defragmentation job which may take a long time to complete. Shortest Remaining Time Out of all the jobs queued up at anyone time, this algorithm will prioritise those which have the shortest remaining time to process. Consider a chef cooking several meals at once, he/she may chose to serve those that have the shortest time left to cook, regardless of the time the orders came in.

  20. Multi-Tasking(scheduling, interrupts and the interrupt service routine ) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Scheduling Algorithms Multi-Level Feedback Queue This algorithm makes use of a range of queues, with each queue given a different priority. For example there may be a queue for an input/output requests, one for the shortest jobs but whatever the queue categories, the algorithm can schedule jobs between the queues to ensure the CPU works as efficiently as it can, maximising the quality of the experience for the user.

  21. Peripheral Management(Device Drivers) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Peripheral Management An important job of an operating system is to management peripheral devices. In particular, its role is to provide an interface between software and hardware as one cannot talk to the other. For example, in the case of some audio playing software, the operating system will receive a request from the program to pass on data to the speaker. The operating system will the communicate with the speaker in order to pass this data on, so that it will output the desired sound.

  22. Peripheral Management(Device Drivers) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Buffers and Spooling Because all other devices are so much slower than the CPU, the operating system needs to manage the requests of peripheral devices to use the CPU, as efficiently as possible. For example, if a request to print several documents was made by a user, it would be inefficient for the CPU to be actively waiting for each printing job to complete before dealing with the next printing job. To overcome this, the operating system makes use of a small piece of secondary storage and creates with it, something known as a buffer. This buffer enables spooling to occur. Spooling comes from the term ‘Simultaneous Peripheral Operations Online’. Spooling is where peripheral device requests are added to a queue / buffer, with each request then being seen to in turn – this allows the CPU to be freed up to deal with millions of other requests, between the slower peripheral device jobs.

  23. Peripheral Management(Device Drivers) Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Device Drivers Clearly it is impractical for programmers of an operating system to be able to program an OS to be able to communicate with every possible peripheral device as there are so many different types and makes. To get around this, each peripheral device will have a small piece of software known as a device driver. This file has the information that an operating system needs to be able to communicate with the device.

  24. The BIOS Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. The Kernel The kernel is the heart of the operating system and is responsible for looking after “the most low-level hardware operations”. It is the kernel that applications make use of when they want to operate the computer’s hardware. The BIOS So far we have discussed the functions of operating systems. The BIOS is not a function of an OS, nor is it an OS.But without one, the computer will be unable to run the OS. BIOS stands for Basic/Input Output System. When you first switch on your computer, the BIOS will run and its job is to first check that all the components required for a computer to function, are all present and working. This is known as the power-on self-test (POST). After running the POST, the BIOS will load the operating system’s kernel from the boot loader, allowing the operating system to run and load on the computer.

  25. Virtual Machines Learning Objectives: a) The need for, function and purpose of operating systems. e) Distributed, embedded, multi-tasking, multiuser and real time operating systems. b) Memory management (paging, segmentation and virtual memory). c) Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle. d) Scheduling: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time. f) BIOS. g) Device drivers. h) Virtual machines, any instance where software is used to take on the function of a machine, including executing intermediate code or running an operating system within another. Virtual Machines A virtual machine is software. It is a program which takes on the function of a physical machine. It can run an operating system for example. Virtual machines are becoming more and more common as it means that with just one computer, this software can create the illusion that there are several different computers, each running their own operating systems independently, but at massively reduced cost. The components of just one computer being utilised to produce the experience of several computer systems. Virtual machines are also really advantageous when it comes to the portability of programs. Currently, we know that a program needs to be fully translated into machine code in order for the CPU to run the program. The alternative is to run the source code with an interpreter but this reveals the code and makes the program run much slower. Virtual machines provide another option. They can execute something called intermediate code which is neither source code nor machine code. It is a far more efficiently packaged version of source code called Byte Code and because it cannot be read like source code, the programming code is secure. Usually, programs come fully compiled and it will be compiled to be run on only certain types of CPU, but because bytecode is only partially translated, before the code is run, the virtual machine can first check the computer’s hardware before deciding how to translate it, so that it can be executed by that computer’s hardware. Bytecode is therefore highly portable.

  26. Lesson Activity 1 40 mins What are the functions of a CPU? [4] Explain the difference between segmentation and paging and discuss their relative efficiencies when managing memory. [7] Explain what an Interrupt is and the consequential Interrupt Service Routine. [5] Describe the various ways a CPU may carry out multi-tasking. [10] Explain what ‘device drivers’ are and why they are needed. [3] Explain what a virtual machine is. [5]

More Related