Here you can see where actually the operating system fits in. Operating system works in a kernel mode and rest of the software's works in a user mode.
TWO MODES
- User Mode: User mode has limited rights and it can't execute anything by its own. You must be seeing this application (Web Browser) due to this user mode.
- Kernel Mode: In a kernel mode it can execute any instruction and has complete access to hardware.
TWO FUNCTIONS OF OPERATING SYSTEM
There are basically two functions of a modern operating system
- Top to down: Whenever you go from Top to down you will get to see the abstraction provided to application users. As, you are seeing this page and other GUI interface due to the abstraction abstraction provided by operating system else you had to directly deal with hardware which's not so easy.
- Down to Top: And whenever you go from down to top you will get to see that operating system is managing all the hardware which is not so easy and providing abstraction to the user(Here user means applications). Otherwise they had to deal with these complicated hardware's.
ABSTRACTION
It's unnecessary to learn the procedure of how it provides abstraction. Just remember that operating system converts ugly interfaces into beautiful interfaces i.e to provide abstraction to the application programs.
THE OPERATING SYSTEM AS RESOURCE MANAGER
The operating system allows multiple programs to run at the same time and same instant. It also manage,protect and track memory that how much capacity is left and how much the program wants. It also manages all the I/O(Input & Output) devices and other similar resources that includes multiplexing sharing in two different ways that are:
- Time Sharing
- Space Sharing
- Time Sharing: In time sharing multiplexing resources the operating system give each process some time and then give other processes and everyone get some time. But what if a process which has a higher priority wants to execute first but due to the time sharing a CPU might be giving time to a less priority process.
- Space Sharing: In space sharing multiplexing, instead of giving each process some time. It divides up the hardware and give memory to each process so everyone gets entertained.
CPU PIPE-LINING
A CPU cycle includes fetch, decode and the execute. It fetches information from memory and then decodes it to know what it actually wants a CPU to do and then execute according to it. It even handle interrupts if any and that's what a pipe-lining is. A pipe-lining is actually a cycle of CPU but in two different ways that are:
- Three Stage Pipe-lining
- Super-scalar Pipe-lining
- Three-stage Pipe-lining: In a three stage pipe-lining a CPU first fetch the instruction from memory, decodes it to know what it really wants it to do and then execute according to the requirement but before that check interrupts if any and handles it.
- Super-scalar pipe-lining: In a super scale pipe-lining, there are multiple units of fetch decode and execute and as well as there is a buffer that holds the instruction after it's being decoded. It's more efficient in time than that of three-stage pipe-lining but there's an issue that it sometimes execute the instruction out of order which's such a great dispute.
MEMORY
Memory is where a CPU store information after being fetched. There are multiple types of memory that includes registers, cache, main memory, disks, magnetic tape etc. The best people can do is to make a memory hierarchy the reason is that we can use a single memory to store data lets suppose registers, but it will be really costly so for the best people can do is to divide up the memory according to the requirements/needs.
BOOTING THE COMPUTER
Whenever the computer starts, it first checks either there is any RAM, keyboard and other basic I/O presents or not. If yes then it checks for boot devices that includes floppy disk, CD-ROM, disk etc. If there's any peripheral device is present so it executes it first else execute the hard disk where the OS is present.
PROCESS
Any program in execution is known as a process. It means whenever the program is running it's called a process e.g: MS OFFICE and other similar programs. A process is actually a container that holds the information about a program to run. A process has address space which will be unique and individual from other processes. All the information about each process that include its name, PID(Process ID) and other similar things are stored in a table called process table. The key management called the system calls deals with the CREATION AND TERMINATION of each process. Whenever a process wants to communicate with another process to done its job is knows is Inter-Process Communication. If a process creates multiple process so it'll be called as a child process which has the same UID (User Identification)as its parent.
Each person is authorized to use a system is assigned a UID. Every process started has a UID that which person has started it. Users can be members of groups each one has a GID(Group Identification). There is a UID in UNIX which has some special powers that can violate many protection rules.
FILES
OS presents a clean abstract model of device-independent files, There are some system calls for files that are to create a file, to remove a file, to read a file and to write a file. Files hierarchies is deep than that of process. A process is not so long lived but a file is. File hierarchy exists for years but a process do not exists for years. Typically a parent process can create a child process but files can be controlled by many.
SYSTEM CALLS
You must be wondering system calls? Is there any call which a system makes like we call to a person? Yes, you are thinking right but there's obviously a difference between the call we make and the call which system makes.
There are two main functions of an Operating System that are to provide abstraction to the user as well as to manage the computer resources. Managing all the computer resources is transparent.System calls are the only way through which user contact with OS and Hardware. There are different system calls vary from system to system but the underline concept remains same. A procedure library is provided to make system calls from C and other languages.
CPU executes one instruction at a time. Whenever a process needs a system service, it has to execute a trap instruction first and then the control will be transferred to the OS. OS then inspects the parameters to see what actually the requirement of a user and it carries out a system call then the control has to be returned to the instruction for which the system call were made. Unlike procedure calls, system calls runs in kernel mode.
MEMORY LAYOUT
Process in Unix have their memory divided into three segments that includes data segment, stack segment and text segment.
- Text Segment: In text segment there's the full code of a program.
- Data Segment: In data segment there're only variables of the program.
- Stack Segment: In the stack segment there are functions of the program.
It should be noted that Stack segment grows downward, wherever the data segment grows upward.
OPERATING SYSTEM STRUCTURE
Till now we have seen how the operating system looks from outside. Now, it's time to look inside of the operating system.
MONOLITHIC SYSTEMS
In monolithic systems, the services (system calls) provided by the operating system are requested by putting the parameters in a well-defined place (e.g., on the stack) and then executing a trap instruction. This instruction switches the machine from user mode to kernel mode and transfers control to the operating system.
The operating system then fetches the parameters and determines which system call is to be carried out. After that, it indexes into a table that contains in slot k a pointer to the procedure that carries out system call. This organization suggests a basic structure for the operating system: - A main program that invokes the requested service procedure.
- A set of service procedures that carry out the system calls.
- A set of utility procedures that help the service procedures.
In this model, for each system call there is one service procedure that takes care of it and executes it. The utility procedures do things that are needed by several
service procedures, such as fetching data from user programs. This division of the procedures into three layers.
LAYERED SYSTEMS
A generalization of the approach of is to organize the operating system as a hierarchy of layers, each one constructed upon the one below it.
- Layer 0: Layer 0 is used to allocate which processor will be given first and which will be given after it. As well as this layer is also used for multi-programming that is switching between processes with interrupt handling if any,
- Layer 1: Layer 1 does the memory management and allocate the process some main memory and if there's not an enough space so it keep it in a drum that is called virtual memory but a process shouldn't worry about whether it's in main memory or in drum.
- Layer 2: Layer 2 does the work of process communication. Whenever the process wants to interact with another by interrupt or by inter-process communication so it helps in letting it communicate. It might wants to communicate just to complete it works which is dependent on another process.
- Layer 3: Layer 3 does the work of Input and Output management and buffering the information streams to and from them
- Layer 4: Layer 4 is where the user program is and it doesn't need to worry about where the process, memory, console or I/O management.
- Layer 5: Layer 5 belongs to the system operator process.
MICROKERNEL
The basic idea behind the microkernel design is to achieve high reliability by splitting the operating system up into small, well-defined modules, only one of which-the microkernel-runs in kernel mode and the rest run as relatively powerless ordinary user processes.
The MINIX 3 microkernel is only about 3200 lines of C and 800 lines of assembler for very low-level functions such as catching interrupts and switching processes. The C code manages and schedules processes, handles inter-process communication (by passing messages between processes), and offers a set of about 35 kernel calls to allow the rest of the operating system to do its work. These calls perform functions like hooking handlers to interrupts, moving data between address spaces, and installing new memory maps for newly created processes. The process structure of MINIX 3 shown below, with the kernel call handlers labeled System. The device driver for the clock is also in the kernel because the scheduler interacts closely with it. All the other device drivers run as separate user processes.
Outside the kernel, the system is structured as three layers of processes all running in user mode. The lowest layer contains the device drivers. Since they run in user mode, they do not have physical access to the 110 port space and cannot issue 110 commands directly. Instead, to program an Input/Output device, the driver builds a structure telling which values to write to which 110 ports and makes a kernel call telling the kernel to do the write. This approach means that the kernel can check to see that the driver is writing (or reading) from I/0 it is authorized to use. Consequently, (and unlike a monolithic design), a buggy audio driver cannot accidentally write on the disk. Above the drivers is another user-mode layer containing the servers, which do most of the work of the operating system. One or more file servers manage the file system(s), the process manager creates, destroys, and manages processes, and so on. User programs obtain operating system services by sending short messages to the servers asking for the POSIX system calls. For example, a process needing to do a read sends a message to one of the file servers telling it what to read. Then above the servers layer there's the layer where the user programs resides in.
The MINIX 3 microkernel is only about 3200 lines of C and 800 lines of assembler for very low-level functions such as catching interrupts and switching processes. The C code manages and schedules processes, handles inter-process communication (by passing messages between processes), and offers a set of about 35 kernel calls to allow the rest of the operating system to do its work. These calls perform functions like hooking handlers to interrupts, moving data between address spaces, and installing new memory maps for newly created processes. The process structure of MINIX 3 shown below, with the kernel call handlers labeled System. The device driver for the clock is also in the kernel because the scheduler interacts closely with it. All the other device drivers run as separate user processes.
Outside the kernel, the system is structured as three layers of processes all running in user mode. The lowest layer contains the device drivers. Since they run in user mode, they do not have physical access to the 110 port space and cannot issue 110 commands directly. Instead, to program an Input/Output device, the driver builds a structure telling which values to write to which 110 ports and makes a kernel call telling the kernel to do the write. This approach means that the kernel can check to see that the driver is writing (or reading) from I/0 it is authorized to use. Consequently, (and unlike a monolithic design), a buggy audio driver cannot accidentally write on the disk. Above the drivers is another user-mode layer containing the servers, which do most of the work of the operating system. One or more file servers manage the file system(s), the process manager creates, destroys, and manages processes, and so on. User programs obtain operating system services by sending short messages to the servers asking for the POSIX system calls. For example, a process needing to do a read sends a message to one of the file servers telling it what to read. Then above the servers layer there's the layer where the user programs resides in.
CLIENT-SERVER MODEL
A slight variation of the microkemel idea is to differentiate two classes of processes, the servers, each of which provides some service, and the clients, which use these services. This model is known as the client-server model.
In simple you can understand this client server model by texting. You might text someone and then the desired person replies you whatever you have asked it. Same is client server model. In this client-server model. A client passes a message to an appropriate service and then a service does it work which a client has asked it to do and then passes it back to the client. If the client and server run on the same machine, certain optimizations are possible, but conceptually, we are talking about message passing here. An obvious generalization of this idea is to have the clients and servers run on different computers, connected by a local or wide-area network, as shown below. Since clients communicate with servers by sending messages, the clients need not know whether the messages are handled locally on their own machines, or whether they are sent across a network to servers on a remote machine.
VIRTUAL MACHINES
Before going in deep about the virtual machines lets see what it actually is. A virtual machine is an operating system or application environment that is installed on a dedicated operating system. The end user has the same experience on a virtual machine as they have on dedicated machine.
HYPERVISOR
As we have seen what virtual machine is, now we will get to know about the software that is called hypervisor which take follow the PC client or server's CPU, memory, hard disk, network and other hardware resources completely. It can emulate multiple virtual hardware platforms that are individual from one another, allowing virtual machines to run different operating system lets suppose LINUX and Windows on the same underlying physical host. Virtualization save costs by reducing the need of physical hardware systems. There are two types of hypervisor.
- Hypervisor-1
- Hypervisor-2
HYPERVISOR-1
Hypervisor-1 which is considered a bare-metal hypervisor and runs directly on top of hardware. The Type 1 hypervisor is often referred to as a hardware virtualization engine.
HYPERVISOR-2
Hypervisor-2 operates as an application on top of an existing operating system as shown below.
EXOKERNEL
Rather than cloning the actual machine, as is done with virtual machines, another strategy is partitioning it, in other words, giving each user a subset of there sources. Thus one virtual machine might get disk blocks 0 to 1023, the next one might get blocks 1024 to 2047, and so on.
The advantage of the exokemel scheme is that it saves a layer of mapping. In the other designs, each virtual machine thinks it has its own disk, with blocks running from 0 to some maximum, so the virtual machine monitor must maintain tables to remap disk addresses (and all other resources). With the exokemel, this remapping is not needed. The exokernel need only keep track of which virtual machine has been assigned which resource. This method still has the advantage of separating the multi-programming (in the exokernel) from the user operating system code (in user space), but with less overhead, since all the exokernel has to do is keep the virtual machines out of each other's hair.
As i have just discussed and highlighted the important things which should be known to you. Hope you enjoyed reading my blog and i hope that you have got to know a lot about the operating system and other things related to it. I'll be really thankful if you will give your precious time by commenting and letting me know whether you liked it or not or what are your desired interests? Thank you once again for reading!!



















That's a wonderfull initiative. You're doing a great job. Keep it up :)
ReplyDeleteThank you so much Wajeeha :)
DeleteIt's very good
ReplyDeleteThank you so much. :)
DeleteThank you. :)
ReplyDeleteReally informative! Keep it up :) Efforts (Y)
ReplyDeleteThank you Sara :)
DeleteReally informative! Keep it up :) Efforts (Y)
ReplyDeleteThank you :)
DeleteFeeling proud to see you Umair Adil. You are a great student and providing very beneficial knowledge to all.
ReplyDeleteLots of Appreciation to you. Love you :)
Thank you so much bro. It means a lot.:)
DeleteYour skills of writing 👍 really apreciable
ReplyDeleteYour skills of writing 👍 really apreciable
ReplyDelete