Operating System

maxresdefault.jpg
By OpenCanvas

Operating system is made up of a set of softwares which controls the resources of hardware and also provide services for applications. It is like the bridge between hardware and application softwares.

Major OS are MacOS, Windows, Linux, etc.

There are four main managers: memory manager, process manager, device manager, and file manager. In the following blog post I will explain each of them in detail.

Memory Manager

WX20171205-160952@2x.png
Dynamic partitions by OpenCanvas

It’s responsible for allocating and deallocating resources. There are three ways of managing memory.

Single user contiguous

The memory takes in one job, then process and clear, and then process the next job.

If the job’s size is larger than memory avaible, it will not be executed.

Disadvantage: impractical for complex system

Contiguous Partitions

Fixed partitions

More than a single job are stored in partition memory table to keep track of their usage. The partition is static unless re-boot.

dynamic partitions

Give memory requested, so memory is not wasted.

When memory is deallocated (cleared to make free), adjacent blocks are joined.

Allocation methods for contiguous partitions

– first fit allocation: use first eligible partition
– best fit allocation: look for the smallest: slower but more efficient.

Non-Contiguous Partitions

Instead of storing the whole program, we can split the job. In this case we use virtual memory.

There are 4 schemes:

Paged map allocation

Divide jobs to equal sized parts.

The sections of disk are called sectors/blocks; section of the main memory is call page frames.

preparation steps: 1. determine No. of pages in the program, 2. locate empty page frames.

Disadvantage: Since there is need to track the jobs, complexity is increased.

There are three tables:
1. Job table, which includes Job’s size & PMT
2. Page map table (PMT), includes page No. & page frame No.
3. Memory map table includes page frame&state.

Demand paging

Pages are loaded on demand; Page map table adds three columns: “status, modified, referenced.”

Page replacement policy determines how to replace page:
1. first in first out
2. least recently used
3. least frequently used
4. most recently used

Segmented memory allocation

Split to segments that reflect the nature and structure of the code.

Segment map table: segment No. & page pointer

Mixture of segmented memory allocation & demand paging memory allocation

It combines the logic of segmented memory allocation and the physical benefit of paging; It uses both segment map table and page map table plus the information of read, write, and execute. Disadvantage: Too complex for keeping track of all the information.

Why virtual memory good?

It uses back up memory, hard drive, to extend memory capacity.

Process Manager

Three factors that affect the processing: performance, speed, bandwidth.

CPU has its clock speed, and its bandwidth determines how much info can be processed in one instruction.

The processor’s memory is cache, which is 5/10 faster than RAM.

process scheduler

It includes job scheduler and process scheduler.

For each job, there may be multiple processes.

5 states of processing:
hold: job schedule hold the process,
ready: and the process is into a ready state
run: the the job is processed. Concern the performance, it might go back to ready state. If there’s a process failure (it shows IO request page fault),
wait: then it will wait until it finds correct resource.
finish

Process control block: contain information about jobs, which are placed in queue.

Three limitations scheduling policy

  1. Finite number of resource
  2. Locked resources, meaning that they are not shared.
  3. Need the user to reassign jobs.

We don’t want resource hogging: a job make use of all resources, need to intervene.

Pre-emptive

The system is able to intervene the process, examples:

  1. Pre-emptive version of SJN: shortest remaining time(SJN);
  2. Round robin, there is predetermine time slice given to each job, called a time quantum. When the time expired, the job changes and waits in queue;
WX20171205-161143@2x.png
Round Robin, by OpenCanvas

Non pre-emptive

System need to wait for the each process to complete, examples:

  1. First come first serve (FCFS), response time is not efficient; unpredictable;
  2. SJN: short job next. It needs accurate run-time estimate;
  3. Priority scheduling: administrator first, user’s basic process later.

Multiple level queue: multi priority, variable time quantums, aging queue.

Three problems of scheduling:

Deadlock: all resources are locked.
Livelock: some resources are released but put back to locked state.
Starvation: one process always gets resource, others always wait.

Device Manager

It controls the external devices in coordination with the internal system.

4 responsibilities

1. status of each device
2. enforce policies
3. allocation
4. diallocation

3 types of devices

  1. dedicated device: one at a time, like printers
  2. shared device: assigned to multiple processes,
  3. virtual devices: spooler, which controlled by program. Put job in queue and take them one at a time. Good spooler can cancel or reorder the jobs.

Direct access storage

  1. Fix head magnetic disk storage: The circles on the disk are called tracks. It has fixed r/w heads.
  2. Movable head magnetic disk (hard disk): It has 1 read-write head. Adv: more space for data, reduced cost; Dis: constrained by the speed of the moving head.
  3. Optical disk storage: It moves at constant angular velocity. It uses laser to access the data. Blue ray disk can store data in thinner layers, thus increasing storage.
  4. Flash memory: It is electrical erasable programmable (EEP) read-only memory. It was used to boot-up (ROM), but now it is used in more scenarios like Solid State Drives.

File Manager

It is related to the managing of data, program, compiler, installed applications, and set permissions of access, etc.

It is in charge of physical component, information resources, and policies.

Its 4 tasks

  1. Keep track of where each file is store,
  2. Use a policy to determine how the file should be store,
  3. Allocate each file when the user has been cleared for access.
  4. Deallocate the file when it is returned to storage.

Network manager

It provides a way for users to share hardware and software resources while controlling users access.

GUI

OS has to provide a link between the user and the computer hardware, and GUI is the solution

Types of user interfaces

Linux_command-line._Bash._GNOME_Terminal._screenshot.png
CLI. From Wiki

Graphical User Interfaces (GUIs);
Command Line Interfaces (CLIs);
Natural Language Interface (NLIs);
Menu Based Interface (MBIs);

The MacOS and Windows are both GUIs. Linux might have CLIs when there is no GUI.

Conclusion:

Operating system is the foundation of all the application softwares. As the hierarchy of software shows, software includes system softwares and applications softwares. System softwares connect the hardware to provide crucial service to applications. Therefore, it’s important to know how the OS works in order to better understand computers.

 

 

Leave a comment

Website Built with WordPress.com.

Up ↑