An operating system acts as an intermediary betwen the user of a computer and computer hardware. The purpose of an operating system is to provide an environment in which a user can execute programs conveniently and efficiently.
An operating system is a software that manages computer hardware. The hardware must provide appropriate mechanisms to ensure the correct operation of the computer system and to prevent user programs from interfering with the proper operation of the system.
Process is an instance of a program in execution. For example, opening a web browser is a process. A user can open several copies of the web browser, each copy is a separate process. A program by itself is not a process. A program becomes a process when an executable file is loaded into memory.
The memory layout of a process is typically divided into: Text section, Data section, Heap section, and Stack section.
The operating system is responsible for managing all the processes running on a computer. OS allocates each process a certain amount of time to use the processor. OS also allocates various other resources that processes will need, such as computer memory or disks. To keep track of the state of all the processes, the operating system maintains a table known as the process table. Inside this table, every process is listed along with the resources the process is using and the current state of the process.
States of process
Processes can be in one of three states: running, ready, or waiting.
The running state means that the process has all the resources it needs for execution and it has been given permission by the operating system to use the processor. Only one process can be in the running state at any given time. The remaining processes are either in a waiting state or a ready state.
Waiting state means the process is waiting for some external event to occur such as user input or disk access.
Ready state means the process is waiting for permission to use the processor.
In a real operating system, the waiting and ready states are implemented as queues that hold the processes in these states.
Thread is a single sequence stream within a process. Because threads have some of the properties of processes, they are sometimes called lightweight processes. Threads are a popular way to improve the application through parallelism. For example, in a browser, multiple tabs can be different threads. MS Word uses multiple threads, one thread to format the text, another thread to process inputs, etc.
Difference between process and thread
i. Processes run in separate memory space.
Threads (of the same process) run in a shared memory space.
Benefits of multithreaded programming
It makes the system more responsive and enables resource sharing. It leads to the use of multiprocess architecture. It is more economical and preferred.
What is Thrashing?
Thrashing is a situation when the performance of a computer degrades or collapses. Thrashing occurs when a system spends more time processing page faults than executing transactions. While processing page faults is necessary in order to appreciate the benefits of virtual memory, thrashing has a negative effect on the system. As the page fault rate increases, more transactions need processing from the paging device. The queue at the paging device increases, resulting in increased service time for a page fault.
What is virtual memory?
Virtual memory creates an illusion that each user has one or more contiguous address spaces, each beginning at address zero. The sizes of such virtual address space are generally very high. The idea of virtual memory is to use disk space to extend the RAM. Running processes don't need to care whether the memory is from RAM or disk. The illusion of such a large amount of memory is created by subdividing the virtual memory into smaller pieces, which can be loaded into physical memory whenever they are needed by a process.
What is demand paging?
The process of loading the page into memory on demand (whenever a page fault occurs) is known as demand paging.
What is a kernel?
A kernel is the central component of an operating system that manages the operations of computers and hardware. It basically manages the operations of memory and CPU time. It is a core component of an operating system. Kernel acts as a bridge between applications and data processing performed at the hardware level using inter-process communication and system calls.
What is a buffer?
A buffer is a memory area that stores data being transferred between two devices or between a device and an application.
What are the different scheduling algorithms?
First-Come, First-Served (FCFS)
Shortest-Job-Next (SJN)
Priority
Shortest Remaining Time
Round Robin
Multiple-Level Queues