Operation System
https://www.tutorialspoint.com/operating_system/index.htm
An Operating System(OS) is a collection of software that manages computer hardware resources and provides common sservices for computer programs. The operating system is a vital component of the system software in a computer system.
OS is a programs that acts as an interface between the user and the computer hardwares and controls the execution of all kinds of programs.
Basic tasks: file management, memory management, process management, handling input and output, and controlling peripheral devices such as disk drives and printers.
Memory Management: management of primary memory or main memory.
Processor management: process scheduling.
1. keeps tracks of processor and status of process. Traffic controller.
2. Allocates the processor(CPU) to a process
3. De-allocates processor when a progress is no longer required.
Device management:
1. Keeps tracks of all devices. I/O controller
2. Decides which process gets the device when and for how much time.
3. Allocates the device in the efficient way
4. De-allocates devices.
File management
1. keeps track of information, location, uses, status etc. The collective facilities are often known as file system.
2. Decides who gets the resources
3. Allocates the resources
4. De-allocates the resources
Operating System - Services
1. It provides programs an environment to execute
2. it provides users the services to execute the programs in a conveninent manner.
Process: defined as an entity which repesents the basic unit of work to be implemented in the system.
divided into four sections: stack, heap, text and data.
a progress is a dynamic instance of a computer program.
Process Life Cycle: Start, Ready, Running, Waiting, Terminated or exit.
Thread: a flow of execution through the process code, with its program counter that keeps track of which instruction to execute next, system registers which hold its current working variables, and a stack which contains the execution history.
A thread shares with its peer threads few information like code segment, data segment and open files, when one thread alter a code segment memory item, all other threads see that.
Difference between process and thread.
Both processes and threads are independent sequences of execution. The typical difference is that threads(of the same process) run in a shared memory space, which processes run in separate memory space.
Advantages of Thread:
- Threads minimize the context switching time.
- Use of threads provides concurrency within a process.
- Efficient communication.
- It is more economical to create and context switch threads.
- Threads allow utilization of multiprocessor architectures to a greater scale and efficiency.
Types of Thread:
User Level Threads: user managed threads.
Kernel level Threads: Operating System managed threads acting on kernel, an operating system core.
Linux kernal Development: Processes are the abstraction of running programs: A binary image, virtualized memory, various kernal resources, an associated security context, and so on.
Threads are the unit of execution in a process: A virtualized processor, a stack, and program state.
Put another way, processes are running binaries and threads are the smallest unit of execution schedulable by an operating system’s process scheduler.
A process contains one or more threads. In single-threaded processes, the process contains one thread. You can say the thread is the process - there is one thing going on. In multi-threaded processes, the process contains more than one thread-there’s more than one thing going on.
Difference between process and thread.
Both of them are independent sequences of execution. Thread is also named lightweight process. A process can contain one more more threads. The typical difference is that threads(of the same process) run in a shared memory space,which processes run in separate its own memory space. if one process is blocked, then no other process can execute until the first process is unblocked, while one thread is blocked and waiting, a second thread in the same task can run. In multiple processes each process operates independently of the others. One thread can read, write or change another thread’s data.
if we open a brower, it is a process, open several tabs, they are threads.
Operating Sytem - Memory Management
is the functionality of an operating system which handles or manages primary memory and moves processes back and forth between main memory and disk during execution. memory locations. allocations unallocated
Process Address Space. Mapping the logical addresses to physical addresses at the time of memory allocation to the program.
Static vs Dynamic Loading:
Static vs Dynamic Linking.
Swapping: known as a technique for memory compaction. is a mechanism in which a process can be swapped temporarily out of main memory(or move) to secondary storage(disk) and make that momory available to other processes.
Fragmentation: As processes are loaded and removed from memory, the free memory space is broken into little pieces.
Paging: PAS is broken into blocks of the same size called pages.
Segmentation:
works very similar to paging but here segments are of variable-length where as in paging pages are of fixed size.
Virtual memory.
A section of a hard disk that’s setup to emulate the computer’s RAM.
Page Replacement Algorithm:
Reference string.
First In First Out(FIFO) algorithm
Optimal Page Algorithm
Least Recently Used(LRU) algorithm:
Page which has not been used for the longest time in main memory is the one which will be selected for replacement.
Easy to implement, keep a list, replace pages by looking back into time.
Page buffering algorithm
To get a process start quickly, keep a pool of free frames.
Most frequently Used(MFU) algorithm.