top of page

Chapter 36 OS Resource Management Techniques

Writer's picture: David BriffaDavid Briffa

Updated: Jan 7

In Chapter 14 we mostly talked about what an Operating System is and why they are so critical to make a device usable. In other chapters we looked at many physical components and devices that make up a computer. Now you are ready to see the immense power of the intangible. The magic of well built software that helps the hardware come alive.



Recap | What is an OS?


Somewhat ✂️ and 📋 from Chapter 14...

The Operating System (OS) is the software that is designed and built for a device with the intention that a human can perform basic functions on the device without needing to know everything about the underlying hardware.



Computer System Onion Diagram

Managing hardware is complex, so users prefer interacting with application software. For this reason, a device generally comes with a number of system utilities (software) in order to hide the complexity of the hardware, for example, the disk clean-up/defragmenter optimises secondary storage organization, but the OS that abstracts out our hardware is the most important one by far!

The Operating System is the most important software because it is the layer that sits between the application software and the computer hardware.
Ms Camilleri's School Laptop

It is imporant that the operating system is optimised for a particular computer architecture, particularly the CPU. In fact, this is why when we download operating systems or applications the bit-size match the word length of the CPU. Not doing so will affect performance or functionality negatively. A 32-bit operating system installed on a 64-bit architecture will not utilise computer resources well.


Managing Resources


The Operating System must manage the resources of the device so that the human won't have to. Resources mostly refer to the hardware like the CPU, memory, secondary storage, and our input/output devices. People that buy a device, run applications that need to make use of these resources. We already mentioned that users expect to be able to run multiple applications at the same time and this is a huge challenge for the OS because for sure there will be more software than hardware!


Therefore a lot of resources must be shareable. When multiple programs are running at the same time, under the direction of the OS, they are probably sharing:

  • RAM

  • CPU

  • Read-only files


There are resources that cannot be shared meaning that the OS can only grant resource access to one application at any point in time. A few examples of non-shareable resources listed hereunder.


  • A few input/output devices e.g. printer, mouse, keyboard.

  • Some accelerators like cache memory and GPU.

  • Writeable files.

The Operating System is mainly responsible for managing resources like CPU, memory, I/O and files so that multiple applications can run concurrently on a device.

So... how does it do then?


How do all our processes share RAM?


One critical resource the OS manages is memory, especially RAM, which is often shared by multiple running processes. The OS, like a parker, decides where files should stay inside the RAM. Often, not the whole running program is copied into the RAM; only the necessary part that is currently required is loaded. We have far too many processes in our computer and RAM fills up quite quickly. We never really have enough RAM.


What happens when the RAM is full and more space is needed?


The OS uses virtual memory to handle this situation. Virtual memory is a technique where a portion of your secondary storage is used as if it were an extension of the computer's RAM. Therefore, if another part of the program is required and the RAM is full, the OS moves less frequently used data from the RAM to this virtual memory space on the drive. This frees up RAM for the necessary code or data to be placed inside.


Virtual Memory

While the CPU works only on data and programs that are in RAM, virtual memory ensures that the system can continue running smoothly even when physical RAM is insufficient, albeit at a slower speed due to the storage drive's slower access times compared to RAM.


How do all our active programs share CPU?


The CPU is shared between all the programs requesting it, using a method called process scheduling. This ensures that every program gets a fair opportunity to use the CPU. One common scheduling technique is time-sharing, where the OS assigns the CPU to programs in small, fixed units of time called time slices.


For example, the CPU runs Program A for one second, then stops and runs Program B, then stops and runs Program C, before returning to Program A, and so on. This creates the illusion that the CPU is running A, B, and C simultaneously, even though it is only working on one at any given moment.


There are different ways to schedule CPU time, such as Round Robin scheduling and Priority scheduling:


  • Round Robin scheduling ensures that all programs are treated equally by assigning them the same time slice in a cyclic order. It is a fair and simple approach, ideal for systems where all processes have equal importance.



  • Priority scheduling assigns CPU time based on the importance of the processes. A process with a lower priority will only run if no higher-priority processes are waiting. While this ensures critical tasks are handled quickly, it may lead to delays for lower-priority tasks. For example, antivirus software may run at a higher priority than a background media player.



The choice of scheduling method depends on the system's needs, with Round Robin ensuring fairness and responsiveness, and Priority scheduling ensuring that important tasks are done quickly.


How does the OS manage I/O?


The OS must control the input and output of the computer. Let us consider the keyboard as an example.

The OS is always waiting for the signal ‘press a key’ from the keyboard. When this occurs, the OS is responsible for displaying the character pressed on the screen. Same for the mouse, the OS waits for a particular signal to happen. The signal triggered in this case could be ‘move the mouse’, ’right click’, ’left click’ etc. The operating system responds according to the event. If, for example, the left button is clicked, the OS will call the appropriate program to display a menu on the screen. Likewise, the OS sees that the printer is not overwhelmed with documents to print. So, it keeps a record of the files to be printed in a queue so that when a document is printed (all the pages) another document is printed etc.


The OS is able to interpret signals and respond appropriately to them because of the device drivers installed on the computer. A device driver is a computer program that enables the OS to communicate with a specific peripheral device, e.g., a mouse or a keyboard, and consequently it enables the user to give a computer commands and get feedback in an easy way.


Unfortunately, data transfers to and from our I/O devices is extremely slow in comparison to data transfers to and from memory or the CPU. This is problematic for the OS as it is important the the CPU is not idle for long periods of time. To get around this issue, our peripheral use small memory components, called buffers, to temporarily store data. This allows the OS to handle data in batches, reducing delays and keeping the CPU active.



176 views0 comments

Related Posts

See All

Commentaires


Les commentaires ont été désactivés.

Let's keep in touch

Don't miss any updates!

Thanks for submitting!

Have Any Questions?

Thanks for submitting!

© 2023 by Ms Erika Camilleri. Proudly created with Wix.com

bottom of page