Showing posts with label Operating System. Show all posts
Showing posts with label Operating System. Show all posts

Thursday, 22 September 2011

Process Synchronization : Semaphores




Semaphore is a "process synchronization tool" which are assigned by two operation 
a. wait (p)
b. signal (v)
It states that if there are many proceess sharing a same variable, then other process must wait it until the process in critical section is completed, as the process in critical section is completed its send a signal to the other process to enter a critical section.
Semaphores provide mutual exclusion. They are used for process sync and are used to resolve deadlock conditions. 
System semaphores are used by the operating system to control system resources. A program can be assigned a resource by getting a semaphore (via a system call to the operating system). When the resource is no longer needed, the semaphore is returned to the operating system, which can then allocate it to another program.
  For More explanation and Algorithm visit this link. Click here....

Solutions for Critical Section Problem




Summary of Techniques for Critical Section Problem

Software
  1. Peterson's Algorithm: based on busy waiting
  2. Semaphores: general facility provided by operating system (e.g., OS/2)
    • based on low-level techniques such as busy waiting or hardware assistance
    • described in more detail below
  3. Monitors: programming language technique.

Hardware
  1. Exclusive access to memory location
    • always assumed
  2. Interrupts that can be turned off
    • must have only one processor for mutual exclusion
  3. Test-and-Set: special machine-level instruction
  4. Swap: atomically swaps contents of two words

Process Synchronization : Critical Section


Critical Section
  • set of instructions that must be controlled so as to allow exclusive access to one process
  • execution of the critical section by processes is mutually exclusive in time
Critical Section (S&G, p. 166) (for example, ``for the process table'')
repeat
      
      critical section
      
      remainder section
until FALSE


Solution to the Critical Section Problem must meet three conditions...
  1. mutual exclusion: if process  is executing in its critical section, no other process is executing in its critical section
  2. progress: if no process is executing in its critical section and there exists some processes that wish to enter their critical sections, then only those processes that are not executing in their remainder section can participate in the decision of which will enter its critical section next, and this decision cannot be postponed indefinitely
    • if no process is in critical section, can decide quickly who enters
    • only one process can enter the critical section so in practice, others are put on the queue
  3. bounded waiting: there must exist a bound on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted
    • The wait is the time from when a process makes a request to enter its critical section until that request is granted
    • in practice, once a process enters its critical section, it does not get another turn until a waiting process gets a turn (managed as a queue)

Process Synchronization


In computer science, synchronization refers to one of two distinct but related concepts: synchronization of processes, and synchronization of data. Process synchronization refers to the idea that multiple processes are to join up or handshake at a certain point, so as to reach an agreement or commit to a certain sequence of action.

Process synchronization or serialization, strictly defined, is the application of particular mechanisms to ensure that two concurrently-executing threads or processes do not execute specific portions of a program at the same time. If one process has begun to execute a serialized portion of the program, any other process trying to execute this portion must wait until the first process finishes. Synchronization is used to control access to state both in small-scale multiprocessing systems -- in multithreaded and multiprocessor computers -- and in distributed computers consisting of thousands of units -- in banking and database systems, in web servers, and so on.

Wednesday, 14 September 2011

Round Robin Scheduling

It is one of the oldest, simplest, fairest and most widely used scheduling algorithms, designed especially for time-sharing systems. A small unit of time, called timeslice or quantum, is defined. All runnable processes are kept in a circular queue. The CPU scheduler goes around this queue, allocating the CPU to each process for a time interval of one quantum. New processes are added to the tail of the queue.
The CPU scheduler picks the first process from the queue, sets a timer to interrupt after one quantum, and dispatches the process.
If the process is still running at the end of the quantum, the CPU is preempted and the process is added to the tail of the queue. If the process finishes before the end of the quantum, the process itself releases the CPU voluntarily. In either case, the CPU scheduler assigns the CPU to the next process in the ready queue. Every time a process is granted the CPU, a context switch occurs, which adds overhead to the process execution time.
         

Tuesday, 13 September 2011

PCB(Process Control Block)


A process in an operating system is represented by a data structure known as a process control block (PCB) or process descriptor. The PCB contains important information about the specific process including
  • The current state of the process i.e., whether it is ready, running, waiting, or whatever.
  • Unique identification of the process in order to track "which is which" information.
  • A pointer to parent process.
  • Similarly, a pointer to child process (if it exists).
  • The priority of process (a part of CPU scheduling information).
  • Pointers to locate memory of processes.
  • A register save area.
  • The processor it is running on.
The PCB is a certain store that allows the operating systems to locate key information about a process. Thus, the PCB is the data structure that defines a process to the operating systems.
   

System Calls & System Programs


System calls provide an interface between the process an the operating system. System calls allow user-level processes to request some services from the operating system which process itself is not allowed to do. In handling the trap, the operating system will enter in the kernel mode, where it has access to privileged instructions, and can perform the desired service on the behalf of user-level process. It is because of the critical nature of operations that the operating system itself does them every time they are needed. For example, for I/O a process involves a system call telling the operating system to read or write particular area and this request is satisfied by the operating system.
System programs provide basic functioning to users so that they do not need to write their own environment for program development (editors, compilers) and program execution (shells). In some sense, they are bundles of useful system calls.

Operating System Services


Following are the five services provided by an operating systems to the convenience of the users.

Program Execution

The purpose of a computer systems is to allow the user to execute programs. So the operating systems provides an environment where the user can conveniently run programs. The user does not have to worry about the memory allocation or multitasking or anything. These things are taken care of by the operating systems.

Running a program involves the allocating and deallocating memory, CPU scheduling in case of multiprocess. These functions cannot be given to the user-level programs. So user-level programs cannot help the user to run programs independently without the help from operating systems.

 

 

I/O Operations

Each program requires an input and produces output. This involves the use of I/O. The operating systems hides the user the details of underlying hardware for the I/O. All the user sees is that the I/O has been performed without any details. So the operating systems by providing I/O makes it convenient for the users to run programs.
For efficiently and protection users cannot control I/O so this service cannot be provided by user-level programs.


File System Manipulation
The output of a program may need to be written into new files or input taken from some files. The operating systems provides this service. The user does not have to worry about secondary storage management. User gives a command for reading or writing to a file and sees his her task accomplished. Thus operating systems makes it easier for user programs to accomplished their task.
This service involves secondary storage management. The speed of I/O that depends on secondary storage management is critical to the speed of many programs and hence I think it is best relegated to the operating systems to manage it than giving individual users the control of it. It is not difficult for the user-level programs to provide these services but for above mentioned reasons it is best if this service s left with operating system.

Communications

There are instances where processes need to communicate with each other to exchange information. It may be between processes running on the same computer or running on the different computers. By providing this service the operating system relieves the user of the worry of passing messages between processes. In case where the messages need to be passed to processes on the other computers through a network it can be done by the user programs. The user program may be customized to the specifics of the hardware through which the message transits and provides the service interface to the operating system.

Error Detection

An error is one part of the system may cause malfunctioning of the complete system. To avoid such a situation the operating system constantly monitors the system for detecting the errors. This relieves the user of the worry of errors propagating to various part of the system and causing malfunctioning.
This service cannot allowed to be handled by user programs because it involves monitoring and in cases altering area of memory or deallocation of memory for a faulty process. Or may be relinquishing the CPU of a process that goes into an infinite loop. These tasks are too critical to be handed over to the user programs.  A user program if given these privileges can interfere with the correct (normal) operation of the operating systems.

Process Scheduling Technique

Process Scheduling Queue


As processes enter the system they put in job queue. This queue consists of all processes of the system, some process is kept on main memory waiting or ready to execute, so they are placed in the list called ready queue.
So, each operating system consists of other queues when the process is allocated on its CPU. It executes for a while and eventually quite, is interrupted or waits for some particular events to occur such as I/O request I/O request is dedicated to tape driver or sharing device or disk. As we know that system comparing of number of process. The disk may be busy with I/O request of some other process. So, in that case the process has to wait for a disk, such process waiting for particular I/O device is placed in queues called I/O queue.
A common representation of process scheduling is the queuing diagram. The rectangular box represents the queue. The circle represents the resource.
processes scheduling quee
processes scheduling queue
New process always is put in ready queue. It unit in the ready queue until it is selected for execution. Once it is allocated to CPU is starts executing. The several events may occur.
1. A process may issue I/O request then be placed in I/O queue.
2. A process may create a sub process and wait for its termination.
3. A process may be interrupted in between and put back in ready queue. The process continues this cycle until if terminates.

Process State




As the program executes, it generally changes state. A state of the process is defined as the current activities of that process. Each process may have one of the following states:-
a.  New: – the process is being created.
b. Running: – instruction is being executed.
c. Waiting: – a process is waiting for some event (e.g. printer during sending signals) or reception of signal between computer and printer.
d. Ready: – the processor is ready to execute that particular process.
e. Terminated: – the process has finished execution.
Running state implies that process is currently run by the CPU. Ready  to run means that it needs cpu attention and time to run, otherwise it is not  blocked in any sense or in other words, process is waiting state implies that process is not running currently and is waiting for some event to occur( such as i/o completion  or reception of signal). The diagram of process state is given below:-
process states
process states and it's transition

Process Creation


A process can create several new processes. The creating process is called parent process whereas a new process is called child process of that process. New process can further create a more child processes, thus forming tree structure.
processes creation
processes creation
Here, a child has only one parent and a parent has more Childs. Every process will need certain resource (CPU, time, memory, I/O devices) to accomplish its work. If any processes create any sub-process that sub-process may use the resources from the operating system or parent may partition its resources among its child process.
There are several possible ways of executing when any parent creates the child process like:-
a. Synchronous: – if a process is created from another as a synchronous process then the new process must complete execution before the old one can resume.
b. Asynchronous: – if a new process is created asynchronously, then two processes may run concurrently.

Processes


Early computer system allowed any one program to be executed at a base, current days computer system allow multiple program to be loaded in memory and to be executed at the same time or step by step. This executing multiple programs is being resulted as process. A process is the unit of work in a modern time sharing system.
In modern system processing consist of processing a collection of processes. Operating system processes executing system code and a user processes executing user code all this process an executed simultaneously by the CPU.
Even on a single user system, such as Microsoft dos and Macintosh os, a user may be able to run several program at one time, a word processor, web browser and email package.
Even if the user can execute only one program at a time to support or control that particular program, an operating system executes several internal program activities. So, we can theses activities as a process. So, process can be defined as the program in execution compiling of an execution code is process.
A program by its self is not a process. A program is a passive entity such as content of a file or instruction code of particular files whereas process is an active entity. Which specify next instruction to execute and set if associated resources.
Operation on process
A process is usually sequential and consist of a sequence of action that take place one at a time when a set of process is running on a single cpu running the time slicing to multitask, then this is referred to as con current sequential processing or pseudo-parallel processing. If there is more than one CPU available, then processes may be running parallel.
The set of operation that a operating system can perform on process includes:-
a. Create a process
b. Destroy a process
c. Run a process
d. Suspend a process
e. Get process information
f. Set process information
Inter process communication:
Inter process communication is a facility provided by an operating system via which co-operating process can communicate with each other. This facility allows the process to co-operate and synchronize their active IPS. IPS is provided by co message system. IPS is useful in distributed system where the process communication depends on the different computer connected in the network.

What is Kernal


All the operating involving processes are controlled by a part of operating system called kernel or nucleus or core. In modern operating system the kernel is small portion of operating system but plays very important role in computer system. The kernel is interactive with the user mode or user program.
The kernel resides inside primary storage or ram when the computer is opened and controls the system. Other portion of operating system may reside in secondary storage and load in primary memory when needed.
The kernel gives services to the user programs or in depth gives services to the resources.  Kernel is responsible for accepting the interrupt to perform contain task, the user or resource or I/O device gives interrupt signal to kernel and kernel can process the interrupt. In multiuser system, the interrupt is directed to the processor by different user and processor gives service or controls all users, this environment is created by kernel. Here, processes are responsible for rapid response to resource as well as user. The main function of kernel is:-
a. Interrupt handling
b. Process creation and destruction.
c. In multiprocessing system, the control should transfer from one process to another that process is called switching of process.
d. It support file system
e. It support procedure call and return statement.
A Kernel contains different utilities which are used to control and manage computer resources. The utilities of a kernel are:
compiler:
Compiler and interpreter are used to translate high level language to machine understandable form. The compiler translates overall code into machine code. Debugging process is also performing this phrase. In compilation overall code is translate into machine code at a time. If any bug is found in a line at last all program in any line this will show at last. Two types of compiler are used quick-and-dirty compiler and continizing compiler. First compiler is fast and inefficient and second is slow but more efficient.
linker:
In early days, each and every instruction was written to solve the particular problems. even a complex instruction is coded into each machine language program but now a days the instructions can be reuse or instructions are reside into certain location they can be used into program due to this the length of program code will reduce. Large number of sub routine libraries is supplied so that programmers may use system supplied routines to perform common operations. Input and output in particular is normally handled by routine outside the user program. Therefore, machine language programs must normally be combined with other machine language programs to form useful execution unit. The linker links the program code with predefined sub routines. The program execution may be show due to linking. In linking stage, linker combines whatever programs required that loads them directly into primary storage to create an executable file.
Loader:
Programs must be place in primary storage in order to be executed. Associating instructions and data items with particular primary storage locations is an important task of kernel or operating system. This task is performed by sometimes user sometimes by translators and sometimes on the system program called a loader and sometimes on the operating system. The association of instruction and data items with particular storage locations is called binding. In machine language programming, binding is performed at coder section. The loader leads instruction and innate data into primary memory. There are two types of loader called absolute and relocating loader.
A loader is a program that places a program’s instruction and data items into primary storage locations. An absolute loader places instruction and data into the precise locations indicated in the machine language programs. But a relocating loader may load a program at various places in primary storage, depending on the availability of space in primary storage at load time.
shell:
It is the most important system program of operating system. It is a program which accepts user’s command from command line and executes it. A shell is not only the command interpreter and a line editor but also the language with variables, array, function and control statement. It is not graphic oriented. The shell user prompt $, %, # etc. to take a command. The shell carried out the system call editor, compiler, linker, command interpreter are not part of operating system or not part of kernel mode but play very important role in computer program. The shells provide the primary interface between user and operating system. When user log in computer, the shell is started up. It starts up by typing the prompt, or nay sign like $, # etc. and waiting for accepting user command.
In case dos, if two user type date, the shell creates the child process and takes the same program as the child. After completing the child process, it gives result or o/p and wait for another command.

Model of operating system


operating system structure:
An operating system might have many structure. According to the structure of the operating system; operating systems can be classified into many categories.
Some of the main structures used in operating systems are:
1. Monolithic architecture of operating system
monolithic sturucture of operating system
monolithic sturucture of operating system
It is the oldest architecture used for developing operating system. Operating system resides on kernel for anyone to execute. System call is involved i.e.  Switching from user mode to kernel mode and transfer control to operating system shown as event 1. Many CPU has two modes, kernel mode, for the operating system in which all instruction are allowed and user mode for user program in which I/O devices and certain other instruction are not allowed.  Two operating system then examines the parameter of the call to determine which system call is to be carried out shown in event 2. Next, the operating system index’s into a table that contains procedure that carries out system call. This operation is shown in events. Finally, it is called when the work has been completed and the system call is finished, control is given back to the user mode as shown in event 4.
2. Layered Architecture of operating system
The layered Architecture of operating system was developed in 60’s in this approach; the operating system is broken up into number of layers. The bottom layer (layer 0) is the hardware layer and the highest layer (layer n) is the user interface layer as shown in the figure.
layered architecture
layered architecture
The layered are selected such that each user functions and services of only lower level layer. The first layer can be debugged wit out any concern for the rest of the system. It user basic hardware to implement this function once the first layer is debugged., it’s correct functioning can be assumed  while the second layer is debugged & soon . If an error is found during the debugged of particular layer, the layer must be on that layer, because the layer below it already debugged. Because of this design of the system is simplified when operating system is broken up into layer.
Os/2 operating system is example of layered architecture of operating system another example is earlier version of Windows NT.
The main disadvantage of this architecture is that it requires an appropriate definition of the various layers & a careful planning of the proper placement of the layer.
3. Virtual memory architecture of operating system
virtual memory architecture
virtual memory architecture
Virtual machine is an illusion of a real machine. It is created by a real machine operating system, which make a single real machine appears to be several real machine. The architecture of virtual machine is shown above.
The best example of virtual machine architecture is IBM 370 computer. In this system each user can choose a different operating system. Actually, virtual machine can run several operating systems at once, each of them on its virtual machine.
Its multiprogramming shares the resource of a single machine in different manner.
The concepts of virtual machine are:-
a. Control program (cp):- cp creates the environment in which virtual machine can execute. It gives to each user facilities of real machine such as processor, storage I/0 devices.
B. conversation monitor system (cons):- cons is a system application having features of developing program. It contains editor, language translator, and various application packages.
c.    Remote spooling communication system (RSCS):- provide virtual machine with the ability to transmit and receive file in distributed system.
d. IPCS (interactive problem control system):- it is used to fix the virtual machine software problems.
4. client/server architecture of operating system
A trend in modern operating system is to move maximum code into the higher level and remove as much as possible from operating system, minimising the work of the kernel. The basic approach is to implement most of the operating system functions in user processes to request a service, such as request to read a particular file, user send a request to the server process, server checks the parameter and finds whether it is valid or not, after that server does the work and send back the answer  to client server model works on request- response technique i.e. Client  always send request to the side in order to perform the task, and on the other side, server gates complementing that request send back response. The figure below shows client server architecture.
client server model
client server model
In this model, the main task of the kernel is to handle all the communication between the client and the server by splitting the operating system into number of ports, each of which only handle some specific task. I.e. file server, process server, terminal server and memory service.
Another advantage of the client-server model is it’s adaptability to user in distributed system. If the client communicates with the server by sending it the message, the client need not know whether it was send a ……. Is the network to a server on a remote machine? As in case of client, same thing happen and occurs in client side that is a request was send and a reply come back.

Types of Operating System


The main types of operating systems are:
Batch System:
In older days I.e. in second generation computer from 1955-65, the most common device were card reader and tape driver. The common o/p devices were printer, tap driver and punch card. The user does not directly interact with computer system. The programmer responsibility was to prepare the program, data or any information that is to be processed and their punch it on the cards, finally submitted to the computer operator. At some time later, when the computer finish the task whatever job it was running, and operator finally print the result. And hand over to the programmer. Much computer time was wasted while operators were walking around the machine room.
The method adopted to reduce the waste time was batch system.
The operating system used at that time was very simple, as its main job is to transfer the control automatically from one job to next.
The basic idea behind this was to collect the similar information and read them onto a magnetic tape. After collecting a batch of jobs, the tap was brought into the machine room, where it was mounted on the tap driver. The operator then loaded a special program which read the first job on tape and run it, the o/p was written into a second tape instead of being printed. After each job finished the operating system automatically read next job from the tape and begin running it when all the jobs were done. The next batch and brought the output for printing. This method is also called offline batch system.
After some advancement, the printer is connected to the main computer system, in that, as the first job finished instead of writing the o/p on tape, it is directly printed through the printer. This is known as online batch system.
Now a days batch system have been almost replaced by GUI systems , although the internal functions of an operating system are done even now through batch system , batch system is only used by very few technical workers and hobbyist.

Multi processing system
After the batch system operating system designer developed a concept of multiprogramming in which several jobs are in the main memory. As we know that single user cannot keep CPU or any other input output devices busy at all the time. Multiprogramming concept increases the CPU utilisation by managing continuous job to the CPU.
In this concept, memory is being portioned into several pieces, with different job in each partition. The operating system could pick and start the execution of one in the memory. Whatever the job does not need CPU. I.e., the job has to do only with input and output devices and the CPU is idle at that time. The operating system switches from one job to another in the memory and CPU execute a portion of it fill this job issue a request for I/O or the first one has finished its o/p and soon

multi programmed system
multi programmed system

Another main feature of this type of operating system was the ability to read job from the cards onto the disk as soon as they were brought to the computer room. Then, whenever the running job finished, the operating system could load a new job from the disk into the non empty partition and run it. This technique is called spooling. The system adopted this was multiprogramming system.
 advantage of multiprocessing
a. High cpu utilisation
b. It appears that many programs are allocated CPU almost simultaneously.
disadvantage of multiprocessing
a. Jobs may have different sizes therefore, memory management is needed to accommodate then in memory.
b. Many jobs may be ready to run on the CPU, which implies that we need CPU scheduling.

Timesharing System:
Multiprogramming both system provided such an environment where various system resources (CPU, memory, I/O devices) where utilised efficiently. But still interaction of user with computer was not possible.
Time sharing system was advance form of multiprogramming system in which CPU execute multiple task by switching from one task to another. But now user can interact computer system provided direct communication between the user and the computer system. The user can give instruction to operating system through keyboard and wait for immediate result. The response time was approximately less than 1 second.
Time sharing operating system also allows users to share computer. The commands and instructions used in time sharing system was very short so little CPU time are needed for each user. So system switches very fast from one user to another due to very fast switching, user got the impression that entire computer system is dedicated to particular user but it is actually shared with number of users.
In time sharing system, one more important concepts is introduced that is virtual memory, sometime the size of any program is too large to fit on physical memory, in that case, the particular program will not execute.
The main advantage of virtual memory is to store the remaining portion of program that is not fitting in main memory so as to run that particular program.
Time sharing system also provides the concepts of file system, i.e. the proper management of file on the memory or any storage device. UNIX operating system is an example.
Multiprogramming both system provided such an environment where various system resources (CPU, memory, I/O devices) where utilized efficiently. But still interaction of user with computer was not possible.
Time sharing system was advance form of multiprogramming system in which CPU execute multiple task by switching from one task to another. But now user can interact computer system provided direct communication between the user and the computer system. The user can give instruction to operating system through keyboard and wait for immediate result. The response time was approximately less than 1 second.
Time sharing operating system also allows users to share computer. The commands and instructions used in time sharing system was very short so little CPU time are needed for each user. So system switches very fast from one user to another due to very fast switching, user got the impression that entire computer system is dedicated to particular user but it is actually shared with number of users.
In time sharing system, one more important concepts is introduced that is virtual memory, sometime the size of any program is too large to fit on physical memory, in that case, the particular program will not execute.
The main advantage of virtual memory is to store the remaining portion of program that is not fitting in main memory so as to run that particular program.
Time sharing system also provides the concepts of file system, i.e. the proper management of file on the memory or any storage device. UNIX operating system is an example.
Real time operating system:
Real time operating system has well defined fixed time limit i.e. processing must be done within the defined time limit otherwise the system will fail. Some of the applications of the real time operating system are:-
a. System that controls scientific experiments
b. Fuel- injection
c. Air traffic system
d. Control system
Examples of real time operating system are harmony (developed by the national research council of Canada), maruti (university of Maryland) etc
distributed system:
An interesting development that begins taking place during the mid 1980’s is the growth of network of personal computer running distributed operating system. In true distributed system, users should not aware of where their program are being run or where there files are located. That should be handled automatically and efficiently by the operating system. Distributed system allows program to run on several processor at the same time.
Some of the examples of distributed os are ameaba, angle, mach etc.

multiprocessor system
Another concept was developed i.e. Multiprocessor concept. At any given time there is a technological limit on the speed with which a single processor ship can operate. If the system work load cannot be handled satisfactory by the single processor. The response is to apply multiple processors to the problem and is known as multiprocessor environment.
symmetrical multiprocessing system
In symmetrical multiprocessing system, all the operations are essentially identical and perform identical function.
Some of the characteristics are:-
a. Any processor can initiate the I/O operation, can handle any external interrupt and can run any process in the system.
b. All the processes are potentially available to handle whatever need to be done next.
symmetric multiprocessing system
symmetric multiprocessing system
Asymmetrical multiprocessing system
Asymmetry implies some differences between processor. Thus, in asymmetric multiprocessing, different processor do different things. One processor will be the supervisor of other in asymmetric multiprocessing, if the supervisor processor handling the specific work fails, the entire system will go down.
Assymetric multiprocessing system
Assymetric multiprocessing system

What Is Operating System


An operating system is a collection of system programs that control computer and any other peripherals connected to it. The program that hides the truth about the hardware from the programmer and present and a nice simple view a named file that can be read & written as “operating system”. Operating system shields the programmer from the interface, the abstraction offers by the operating system is slower & easier to use than the underlying hardware.
Operating system is collection of software which is close to hardware. We can view operating system as a resource – hardware and software collector.
The main functions of operating system are
1. Implementing using interface
2. Sharing hardware among number of users.
3. Allow user to share data
4. Protecting user from each other
5. Control the execution of programs.

Supervisor and User Mode


The process is executed in the modes supervisor and user mode. In supervisor mode control programs are executed. Actually in this mode the resource is given to user mode or used in a program. Command interpreter (shell), compiler, editor and similar application independent programs. These programs are not part of operating system but controlled by operating systems.
The operating system is that portion of software that runs in kernel mode or supervisor mode. The process or program is kernel mode is mode secure. In kernel mode, interrupt handling operation is performed. The interrupt handler is part of operating system.
To complete the task, the control switches from one mode to another for example in monolithic architecture of Os to complete a task two programs are divided into different events. In event 1, the control switches from user mode to kernel mode. After completing task by kernel than kernel gives o/p or control switches from kernel mode to user mode.
In kernel mode, all the instruction are allowed but in user mode only limited instruction are allowed I/O and contain other instruction may not be allowed. In case of monolithic architecture, I/O instructions are not allowed in kernel mode or supervisor mode.