OPERATING SYSTEMS
Operating System is the most important program that runs on a computer. Every computer must have an operating system to run other programs. Operating systems perform basic tasks, such as recognizing input from the keyboard, sending output to the display screen, keeping track of files and directories on the disk, and controlling peripheral devices such as disk drives and printers. Examples of Operating System are: Windows, Linux, UNIX, DOS, and OS/2 etc.
Scheduling: The assignment of physical processors to processes allows processors to accomplish work. The problem of determining when processors should be assigned and to which processes is called processor scheduling or CPU scheduling.
When more than one process is running, the operating system must decide which one first. This part of the operating system concerned with this decision is called the scheduler, and algorithm it uses is called the scheduling algorithm. The various algorithms that are used for scheduling are: - Multiple-Processor Scheduling, Job Scheduling, Real Time Scheduling, Thread Scheduling etc.
Memory Management: Memory Management is the process of managing the computer memory which consists of primary memory or secondary memory. In this, we allocate the memory portions to programs and software’s after freeing the space of the computer memory. Basically, memory management is of critical importance for operating system because the multi-tasking can take place in the system which switches the memory space from one process to another. Moreover, the concept of the virtual memory is used in the system according to which programs from main memory are loaded to the secondary memory when the space is not large enough to hold the programs.
Inter-Device Communication: Operating system also provides inter device communication. This happens when multiple processes are running and have to be managed by the OS. In such a case it performs a set of instructions on the processes through which the devices make sure that if one device has completed its task then it could pass on to the other task, required it is free.
Processes: A process is an environment in which a program executes. Processes run in the background and provide a common language that allows the operating system to interface with the installed hardware & software to support any applications running on the system.
Deadlocks: A set of processes or threads is deadlocked when each process or thread is waiting for a resource to be freed which is controlled by another process. Here is an example of a situation where deadlock can occur.
Mutex M1, M2;
/* Thread 1 */
while (1) {
NonCriticalSection()
Mutex_lock(&M1);
Mutex_lock(&M2);
CriticalSection();
Mutex_unlock(&M2);
Mutex_unlock(&M1);
}
/* Thread 2 */
while (1) {
NonCriticalSection()
Mutex_lock(&M2);
Mutex_lock(&M1);
CriticalSection();
Mutex_unlock(&M1);
Mutex_unlock(&M2);
}
Suppose thread 1 is running and locks M1, but before it can lock M2, it is interrupted. Thread 2 starts running; it locks M2, when it tries to obtain and lock M1, it is blocked because M1 is already locked (by thread 1). Eventually thread 1 starts running again, and it tries to obtain and lock M2, but it is blocked because M2 is already locked by thread 2. Both threads are blocked; each is waiting for an event which will never occur.
Semaphores: Semaphores are devices used to help with synchronization. If multiple processes share a common resource, they need a way to be able to use that resource without disrupting each other. You want each process to be able to read from and write to that resource uninterrupted.
A semaphore will either allow or disallow access to the resource, depending on how it is set up. One example setup would be a semaphore which allowed any number of processes to read from the resource, but only one could ever be in the process of writing to that resource at a time.