Introduction to Operating Systems¶
Notes¶
- VirtualBox: is a program that allows you to install and run various operating systems (OS) inside your existing operating system using the concept of virtual machines. As the name suggests, a VM is a virtual computer that can run programs and operating systems. Think of it as a computer within a computer 1.
- The purpose of an operating system is to organize and control hardware and software so that the device it lives in behaves in a flexible but predictable way 3.
- Asymmetric operating systems4: use one processor for their own needs and divide application processes among the remaining CPUs. aka. each CPU has a dedicated OS that may not be the same as OS on other CPUs.
- Symmetric operating systems4: divide the work between the various processors, balancing demand versus availability even when the operating system itself is all that’s running, aka. the same copy of OS is running on all CPUs.
- Paging 5: is a storage mechanism that allows OS to retrieve processes from the secondary storage into the main memory in the form of pages.
- In the Paging method, the main memory is divided into small fixed-size blocks of physical memory, which is called frames. The size of a frame should be kept the same as that of a page to have maximum utilization of the main memory and to avoid external fragmentation. Paging is used for faster access to data, and it is a logical concept.
- Buffers6: buffers are used by processes to hold data that is being sent to the process while thr process is waiting (eg. in Suspended state); the the process will transfer data from the buffer to the CPU at a specific rate when the process is in Running state.
- drivers7: are programs that allow the OS to interact with the hardware. For example, suppose an application needs to read some data from a device:
- The application calls a function implemented by the operating system, and the operating system calls a function implemented by the driver.
- The driver, which was written by the same company that designed and manufactured the device, knows how to communicate with the device hardware to get the data.
- After the driver gets the data from the device, it returns the data to the operating system, which returns it to the application.
- An operating system is a set of programs that lies between applications software and the computer hardware.
- System software: is sometimes used interchangeably with operating system, but system software means all programs related to coordinating computer operations. System software does include the operating system, BIOS software, drivers, and service programs 10.
- Desktop virtualization: is a method of simulating a user workstation so it can be accessed from a remotely connected device. organizations can allow users to work from virtually anywhere with a network connecting, using any desktop laptop, tablet, or smartphone to access enterprise resources without regard to the device or operating system employed by the remote user.
Introduction to Operating Systems 2¶
- Von Neumann model of computing: fetches instruction from memory, decodes it, executes it, and stores the results back in memory; fetches the next instruction and repeats the process.
- Operating system is responsible for: running programs, allowing programs to share memory, enabling programs to interact with devices…etc.
- virtualization: OS takes a physical resource and makes it appear to be multiple resources (virtual form of itself); thus OS can be called a virtual machine.
- OS exposes an API that have 100s of functions that allow programs to interact with the OS and resources; thus OS is called a standard library.
- OS allows multiple programs to run, access memory, access files; thus OS is called a resource manager.
- CPU virtualization: allows multiple processes to run on the same CPU at the same time, which gives an illusion of multiple CPUs, where each process runs on a virtual CPU.
- Memory virtualization: each process accesses its own virtual address space (address space), which is a subset of the physical memory; then the OS maps the virtual address space to the physical memory. A memory reference within a process does not affect the address space of other processes.
- concurrency: the ability of a program to execute multiple instructions at the same time. multiple threads within the same memory space run concurrently.
- persistence: the ability of a program to store data on disk and retrieve it later.
- file system: is a part of OS in charge of managing persistent data.
- what OS actually does:
- it takes physical resources, such as a CPU, memory, or disk, and virtualizes them.
- It handles tough and tricky issues related to concurrency.
- it stores files persistently, thus making them safe over the long-term.
Design Goals of an Operating System¶
- Abstraction makes it possible to write a large program by dividing it into small and understandable pieces, to write such a program in a high-level language like C without thinking about assembly, to write code in assembly without thinking about logic gates, and to build a processor out of gates without thinking too much about transistors.
- performance: OS must be as performant as possible, by minimizing the overheads. overheads come in form of extra work that the OS does to provide a service to the user which translates to extra time, extra code instructions, extra memory usage …etc.
- protection: OS must provide protection between applications and between applications and the OS itself. OS must make sure that one application (possibly malicious) cannot access the memory of another application, and that an application cannot access the OS itself. OS provide protection by isolating processes from each other and from the OS itself.
- reliability: OS must run non-stop with zero down-time and as less bugs, failures, and crashes as possible.
- energy efficiency: OS must be energy efficient, by minimizing the energy consumption of the device.
- security: OS must provide security by protecting the device from malicious applications and users.
- mobility: OS must be able to run on different devices, such as laptops, tablets, smartphones, and smartwatches.
OS history¶
- Early Operating Systems: Just Libraries:
- OS was a set of commonly used functions. eg, low-level I/O functions.
- one program runs at a time with human operator watch; operator was deciding which instruction to execute next.
- the mode of computing was batch processing. as a number of jobs were set up and then run in a“batch” by the operator
- Beyond Libraries: Protection:
- Since multiple programs were running on the same machine, programs data need not to be accessed by other programs.
- file system was introduced to manage file access for each program.
- OS transformed from a library to a system, and start doing system calls instead of procedure calls.
- system calls raises the hardware privilege level (kernel mode), while the procedure call works on user mode.
- system calls get initiated using a special instruction, trap. which triggers the trap handler previously defined in the hardware and toggles the kernel mode.
- when the system call ends, it transfers the control back to the user using return-from-trap instruction.
- The Era of Multiprogramming:
- starts with introduction of minicomputer.
- multiprogramming became common place due to the desire to make better use of machine resources.
- OS would load a number of jobs into memory and switch rapidly between them, thus improving CPU utilization.
- Issues of concurrency and memory protection were introduced.
- UNIX OS was introduced in 1969 by Ken Thompson and Dennis Ritchie at Bell Labs.
- UNIX got ideas from OSes like Multics from MIT and Time-Sharing System (TSS).
- The Modern Era:
- starts with the introduction of personal computers.
- DOS was the first OS for personal computers.
- Linux was introduced in 1991 by Linus Torvalds based on UNIX.
- many mistakes were made in the designs of early PC OSes, like not having a memory protection, or bad designed job scheduling.
How operating systems work 3¶
- Not all computers have operating systems, eg, Ovens, microwaves, and other simple appliances which use embedded systems.
- OS functions:
- It manages the hardware and software resources of the system. In computers, tablets and smartphones these resources include the processors, memory, disk space and more.
- It provides a stable, consistent way for applications to deal with the hardware without having to know all the details of the hardware.
- types of OS:
- Real-time operating system (RTOS): manages machines and science equipments; has little user interface. no end-user utilities (sold as sealed box).
- Single-user, single task: eg, MS-DOS.
- Single-user, multitasking: eg, Windows.
- Multiuser: eg, Unix, VMS and mainframe operating systems, such as MVS.
- Distributed: the OS uses multiple computers at the same time as in giant server farms.
- when turning a computer on:
- BIOS (basic input/output system) or UEFI (Unified Extensible Firmware Interface) is loaded from the ROM chip on the motherboard.
- BIOS/UEFI code is executed to examine the hardware and OS is legitimate and secure.
- BIOS/UEFI runs the boot loader.
- boot loader loads the OS into memory.
- OS is loaded into memory and starts running.
- OS functions:
- Processor management.
- Memory management.
- Device management.
- Storage management.
- Application Interface.
- User Interface.
- System Security Management.
Process Control Block¶
- Process Control Block (PCB) is a data structure that contains all of the information needed to keep track of a process when switching. and typically contains:
- process ID.
- pointers to the locations in the program and its data where processing last occurred.
- registers content.
- states of various flags and switches
- pointers of the upper and lower bounds of memory required by this process.
- list of files opened by this process.
- the priority of this process
- states of all i/o devices needed by the process.
- Each process has a status associated with it. Many processes consume no CPU time until they get some sort of input.
- For example, a process might be waiting for a keystroke from the user. While it is waiting for the keystroke, it uses no CPU time. It is suspended.
- When the keystroke arrives, the OS changes its status. When the status of the process changes from pending to active, for example or from suspended to running, the information in the process control block (PCB) must be used like the data in any other program to direct execution of the task-switching portion of the operating system.
- thrashing: happens when too many processes are in memory and the OS is constantly swapping them in and out of memory. swapping become more difficult and takes more memory to store the PCBs of all running processes. this causes the OS to spend a lot of time swapping processes, than the time of running processes; and the user to experience a slow system.
Pros and cons of Virtualization in Cloud Computing 8¶
- Virtualization is the creation of Virtual Version of something such as server, desktop, storage device, operating system etc.
- Thus, Virtualization is a technique which allows us to share a single physical instance of a resource or an application among multiple customers and an organization.
- Virtualization often creates many virtual resources from one physical resource.
- Host machine: the physical machine that is hosting the virtual machine which in turn is called the guest machine.
- Virtualization is important in cloud computing because it allows the vendors to provide a single physical machine to multiple customers by selling (or renting) virtual machines on the physical one. Thus cloud vendor’s can virtualize their single big server and provide smaller spec server to multiple customer’s.
- Pros of Virtualization in Cloud Computing :
- Hardware efficiency: a single hardware can be virtualized and rented to multiple customers, which reduced cost of hardware on both vendor and customer side.
- Availability increase: new instances of virtual machines are available to hire at any time. unused virtual machines can be destroyed and the resources re-virtualized for new renters.
- disaster recovery: backup and machine duplications became easier and faster, even real time data backup recovery and mirroring become easy so recovery from disaster is faster and with 0 data loss.
- energy efficiency: less physical hardware means less power consumption.
- quick and easy setup: hire a virtual machine and start using it in minutes; as opposite to physical machine which takes time to purchase, delivery, install, configure and start using.
- easier migrations: virtual machines can be migrated from one physical machine to another in minutes.
- Cons of Virtualization in Cloud Computing :
- Data security: our data is hosted on the vendor’s resources which puts it in a vulnerable position. if the vendor is hacked, our data is also at risk.
- Learning new infrastructure: As Organization shifted from Servers to Cloud. They required skilled staff who can work with cloud easily.
- High initial investment: It is true that Virtualization will reduce the cost of companies but also it is truth that Cloud have high initial investment.
Operating System - Services 9¶
services provided by OS include:
- Program execution:
- each program is encapsulated in a process and process context (process control block).
- OS handles all the details of process creation, loading into memory, execution, synchronization, communication, deadlock handling, and termination.
- I/O operations:
- IO subsystem comprises of IO devices, IO controllers, and IO drivers.
- OS manages communications between user and IO devices.
- File system manipulation: OS allow programs to interact with files and directories.
- Communication:
- In case of distributed systems which are a collection of processors that do not share memory, peripheral devices, or a clock, the operating system manages communications between all the processes.
- Multiple processes communicate with one another through communication lines in the network.
- OS handles routing and connection strategies, and the problems of contention and security.
- Communication may be implemented by two methods, either by Shared Memory or by Message Passing.
- Error detection:
- An error may occur in CPU, in I/O devices or in the memory hardware.
- OS constantly checks for errors and takes appropriate action.
- Resource allocation:
- In case of multi-user or multi-tasking environment, resources such as main memory, CPU cycles and files storage are to be allocated to each user or job.
- OS manages all kind of resources using schedulers.
- Protection and security:
- Considering a computer system having multiple users and concurrent execution of multiple processes, the various processes must be protected from each other’s activities.
- OS manages all access to system resources, I/O devices, and files; and provides mechanisms for access control and authentication.
References¶
-
Abubakar, M. (2022, May 11). How to install linux in VirtualBox. How-To Geek. https://www.howtogeek.com/796988/how-to-install-linux-in-virtualbox/ ↩
-
Arpaci-Dusseau, R. H., & Arpaci-Dusseau, A. C. (2018). Operating systems: three easy pieces (1.01 ed.). Arpaci-Dusseau Books. https://pages.cs.wisc.edu/~remzi/OSTEP/ ↩
-
Franklin, C., & Pollette, C. (2021, November 18). How operating systems work. howstuffworks. https://computer.howstuffworks.com/operating-system.htm ↩↩
-
University of Massachusetts Amherst. Electrical and Computer Engineering. Operating systems - week1 homework solution. https://web.archive.org/web/20190320223658/http://ecs.umass.edu/ece/andras/courses/ECE397A/homeworks/hw1soln.html ↩↩
-
Guru99. Paging https://www.guru99.com/paging-in-operating-system.html ↩
-
buffers and queues https://www.ciscopress.com/articles/article.asp?p=24109&seqNum=11 ↩
-
Drivers. https://learn.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/what-is-a-driver- ↩
-
Pros and cons of Virtualization in Cloud Computing https://www.geeksforgeeks.org/pros-and-cons-of-virtualization-in-cloud-computing/?tab=article ↩
-
Operating system - services. (n.d.). tutorialspoint. https://www.tutorialspoint.com/operating_system/os_services.htm# ↩
-
Operating systems. (n.d.). The University of Rhode Island. web.uri.edu. https://homepage.cs.uri.edu/faculty/wolfe/book/Readings/Reading07.htm ↩