AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=929&pId=-1
Operating Systems: Concepts and Terminologies
page
by Joydip Kanjilal
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 57862/ 89

Introduction

The continued development of applications around the IT industry and the demand for better environments thereafter compels the operating system designers to design more and more Operating Systems that are efficient enough to keep pace with the changing times.  However, the core concepts of these Operating Systems would continue to be the same irrespective of the interfaces and features that these Operating Systems would provide to the end users.  This is a conceptual article that explains the important concepts and terminologies related to Operating Systems in a lucid language.

What is an Operating System?

An Operating System is a set of programs designed internally to provide an interface to the user and an environment to work on.  The following are the basic functions of an Operating System.

·         Processor Management

·         Memory Management

·         File and IO Management

·         Peripheral Management

·         Command Interpretation

An Operating System acts as manager of resources and controls the functioning of various components of the system.  It is responsible for the proper operation of the Input Output devices in the computer system.

Processor Management

This relates to the Operating System’s activity of managing the processor in the system, i.e. allocating and de-allocating of the processor to the process.  The Operating System decides the same based on the priority of the process depending if there exists any and certain pre-defined algorithms.  The following section explains some related terminologies.

Process

A process may be defined as the running instance of a program characterized by a change of state and attributes.  Each and every process maintains a Process Control Block or PCB of its own.

Process Control Block

A process control block (PCB) is a data structure that contains information related to a running process.  These include:

·         Process ID

·         Processor Information

·         Process State

·         Process Priority

·         Stack information

·         Memory information at which the process has been loaded

Process States

A process changes its state from one state to another depending on its required activity.  The process can be in one of the following states.

·         Ready

·         Running

·         Suspended

Thread

A thread is a light weight process.  It is the smallest unit of CPU utilization and is also the path of execution within a process.  A task is an enhanced form of a thread.  Each and every process should have at least one thread; this is the primary or the main thread of the application.  All other user created threads run in the background and are also called worker threads.  When the application’s main thread terminates so does the application.

User Level Threads

The User Level threads are those that are executed in the User’s memory context and do not make use of System calls.  Therefore, Kernel switching does not occur in User Level threads.

Kernel Level Threads

The Kernel Level threads are those that are executed in the Operating System’s Kernel memory context.  The threads are managed and controlled by the Kernel using System calls.

Inter Process Communication

This refers to the communication between two or more processes for the purpose of data and message transfer.

Multithreading

Multithreading is the ability of the operating system to have at the same of time multiple threads in memory that switch between the tasks.  This is to provide a pseudo parallelism, as if all the tasks are running simultaneously.  This illusion of concurrency is ensured by the Operating System by providing a specific time slice to each and every thread and then switching between the threads very fast once their slice is over.

Multithreading can be of the following types.

·         Serial

·         Cooperative

·         Preemptive

In the serial mode of multithreading a thread is executed by the Operating System and until the execution of that thread is over, any other thread cannot be executed.  Hence, a thread has to wait until the earlier thread's turnaround time is over.  In other words, the currently executing thread monopolizes the processor.  In the Cooperative mode of multithreading, a thread can have the control of the processor as long as it needs without the need to necessarily preempt them.  In order words, in this type of multithreading the control of the processor lies with the executing thread.  In the preemptive mode of operation however, the operating system has control over the processor and decides the time slice for each thread for which it would execute and preempt threads if and when required.  Serial Multithreading is supported by the MS DOS operating system, cooperative multithreading is supported by Windows 3.11, while preemptive mode is supported by Windows 98, NT.

Thread Priorities

Thread priorities are values that can be set to distinguish one thread from another depending on their priorities.  A thread with a higher priority would execute more frequently than a thread having a comparatively less priority.

Multitasking

A task is an enhanced form of a thread.  Multitasking is the logical extension of multiprogramming.  The following list shows the names of some commonly used Operating Systems and the type of multitasking that they support.

·         DOS                           : Serial Multitasking

·         Win 3.11                      : Co-operative Multitasking

·         Win 9x/NT                    : Preemptive Multitasking

·         UNIX                           : Time Sliced Priority Based Multitasking

Multiprocessing

Multiprocessing or parallel processing refers to multitasking on multiple processors.  It is of the following two types.

·         Symmetric

·         Asymmetric

File and I/O Management

This is the module of the Operating System that is responsible for creating and/or deleting files in the file system and managing the input and output of data in the file system.

File System

A File System refers to the arrangement in a secondary storage that is done by the Operating System for the purpose of data storage and retrieval.  The File System of any two Operating Systems is not identical.  The following are the names of the Operating Systems and the respective file systems that they follow.

·         DOS                                       : FAT File System

·         Windows 9x                            : VFAT

·         Windows XP/NT/2000/2003       : NTFS

·         Windows Vista                        : NTFS

·         UNIX                                     : UFS (UNIX File System)

·         Linux                                     : Ext II File System

Note: Windows Vista is now built on the NTFS file system.  Windows Future Storage (WinFS), a relational database based data storage engine, is currently under development and will be introduced later as a free add-on for Windows Vista in late 2006.

Root File System

The Root File System specifies the information related to the files on the disk or the secondary storage.  Typical contents include the following.

·         Name of the file

·         Starting Cluster Number

·         Size of the file

·         Date and Time stamp

·         File Permissions

File Control Block

A File Control Block (FCB) is a data structure that contains information related to the files that are present on a File System.  Even though the contents of the FCB would vary from one Operating System to another, the following are the common parts that it contains.

·         Name of the file

·         Location

·         Size of the file

·         Date and Time stamp

Disk Fragmentation and De-Fragmentation

The files created in the secondary storage are created and deleted as needed.  Allocation of the clusters for a file in the file system is non–contiguous.  The Operating System maintains a free cluster list to keep track of the clusters that are available for use or re-use.  Due to deletions of one or more files in the file system, the clusters that are allocated to a file are not in sequence, but rather they are scattered all over the disk with free clusters or holes in between.  This concept is known as disk fragmentation.  The disk de-fragmentation tools available are responsible for compacting or arranging the clusters of a file contiguously in the disk.

Memory Management

This is the module of the Operating System that manages memory in a system by deciding when to allocate and de-allocate memory to a process, how much to allocate and the scheduling of these processes.  The following section lists the major concepts and terminologies that are related to Memory Management.

Contiguous and Non–Contiguous Memory Allocation

In Contiguous Memory allocation strategies, the Operating System allocates memory to a process that is always in a sequence for faster retrieval and less overhead, but this strategy supports static memory allocation only.  This strategy is inconvenient in the sense that there are more instances of internal memory fragmentation than compared to Contiguous Memory Allocation strategies.  The Operating System can also allocate memory dynamically to a process if the memory is not in sequence; i.e. they are placed in non–contiguous memory segments.  Memory is allotted to a process as it is required.  When a process no longer needs to be in memory, it is released from the memory to produce a free region of memory or a memory hole.  These memory holes and the allocated memory to the other processes remain scattered in memory.  The Operating System can compact this memory at a later point in time to ensure that the allocated memory is in a sequence and the memory holes are not scattered.  This strategy has support for dynamic memory allocation and facilitates the usage of Virtual Memory.  In dynamic memory allocation there are no instances of internal fragmentation.

Kernel

This is the core of the Operating System that is responsible for Memory and Processor Management in the system.  The Kernel in MS DOS Operating System is housed in the msdos.sys file.

Bootstrap Process

This is a process by which an Operating System is loaded from the disk onto the primary memory of the system.  The Bootstrap loader is the module of the Operating System that gets loaded first and is present in the first physical sector of the disk.

Paging

In Virtual Memory Systems, a program in execution or a process is divided into equal sized logical blocks called pages that are loaded into frames in the main memory.  The size of a page is always in a power of 2 and is equal to the frame size.  Dividing the process into pages allows non-contiguous allocation in these systems.

Segmentation

Segmentation is a memory management technique that supports Virtual Memory.  The available memory is divided into segments and consists of two components- a base address that denotes the address of the base of that segment and a displacement value that refers to the length of an address location from the base of that segment.  The effective physical address is the sum of the base address value and the length of the displacement value.

Page Fault

A Page Fault occurs when there is a request for a page that is not available in the main memory. The Page Map Table for such a page has its presence bit not set.  When a page fault occurs, the Operating System schedules a disk read operation to retrieve the page from the secondary storage and load the same to the main memory.

Virtual Memory

Virtual Memory refers to the concept whereby a process with a larger size than available memory can be loaded and executed by loading the process in parts.  The program memory is divided into pages and the available physical memory into frames.  The page size is always equal to the frame size.  The page size is generally in a power of 2 to avoid the calculation involved to get the page number and the offset from the CPU generated address.  The virtual address contains a page number and an offset.  This is mapped to the physical address by a technique of address resolution after searching the Page Map Table.

Demand Paging

In Virtual Memory Systems the pages are not loaded in memory until they are "demanded" by a process; therefore the term, demand paging.  Demand paging allows the various parts of a process to be brought into physical memory as the process needs them to execute.

Thrashing

This is a condition that indicates that due to excessive paging a particular process is in the halted state or executing very slowly.  It is a condition in which a multi-programmed environment is equivalent to a mono-programmed environment.  The causes of thrashing can be attributed to one or more of the following.

·         Increase in the degree of multi programming

·         Insufficient memory at a particular point of time

·         The program does not exhibit locality of reference

Thrashing can be reduced by analyzing the CPU utilization and reducing the degree of multi-programming, which in turn is a non-negative integer that indicates how many programs are in the memory at the same point of time in a multi-programmed environment waiting for its turn to get the processor.

Cache Memory

Cache Memory is a high speed memory in the Random Access Memory (RAM).  The processor looks for data first in the Cache Memory and then depending on whether there is a Cache hit or miss, searches for the same in other parts of the primary memory.

A Cache hit indicates that the data searched for in the Cache by the CPU is available.  The reverse is Cache miss.  Typically the size of the Cache in a system is limited and varies depending on the system’s configuration.

Memory Fragmentation

This occurs in dynamic memory allocation when a process is allocated memory blocks that are non-contiguous to support multi-programming.  Memory fragmentation can be of the following two types.

·         Internal Fragmentation

·         External Fragmentation

Internal fragmentation refers to the space that remains unused inside an allocated block.  Internal fragmentation is internal to the allocated memory block and therefore the name.  In dynamic memory allocation systems there are situations when the combined size of the free memory blocks is insufficient to satisfy an incoming request to load a process in the main memory.  This is termed external fragmentation.

Context Switch

This refers to switching the CPU from one process to another by saving the state of the old process in the stack and executing the new process.  The time required to perform this kind of a switch is an overhead as the CPU remains idle at that point of time and it varies from one Operating System to another.

Scheduling

This is an activity of the Operating System that decides the next process to be executed by the CPU.  The module of the Operating System that is responsible for this activity is known as the Scheduler.  There is variety of scheduling algorithms and the algorithm to be used for scheduling depends on the Operating System being used.

Semaphore

A semaphore is the name given to a protected variable that can be assessed by only one process at any point of time.

Synchronization

Synchronization guarantees that only one thread can access the synchronized block of code or synchronized object at any point of time.

Mutual Exclusion

This ensures that only one process performs a certain task to a resource at any point of time.

Critical Section

This is a block of code that can be executed by only one thread at any point of time.  We say that this block is synchronized to ensure thread safety.

Deadlocks

A deadlock is a condition that occurs when two threads attempt to access a resource that has already been locked by them.  In such a situation, none of the threads can execute and they are in a halted state.  This situation can be avoided if both threads acquire these locks on the resources in the same order.

Race Conditions

A race condition is one that can occur due to improper thread synchronization when several threads try to access the same resource at the same time.  As a consequence, the resource remains in an undefined state.  A race condition can be avoided by using thread synchronization to ensure thread safety.

Real Time Operating Systems

A Real Time Operating System (RTOS) is one in which the response to an event takes place in real time (in other words, as and when it is required).  A typical example of a RTOS is the operating system used for flight control.  Real Time Operating Systems are typically of two types, Hard Real Time and Soft Real Time.  In the former the critical tasks are completed in time, while in the latter they are executed based on their priority.

Peripheral Management

The Operating System talks to the devices in a computer system using device drivers that are special programs designed to interact with the physical devices of the system.  The device manager isolates the device drivers from the Kernel of the OS and the user applications from the system’s hardware.  It acts as an interface between the device drivers and both the kernel and user applications.  The salient concepts and related terminologies are discussed in the section that follows.

Interrupt

An interrupt is a signal that informs the processor that a particular device wants its attention.  The processor responds to the request, saves the status of the current activity, executes the requested activity and on completion, retrieves the saved activity and resumes the same.  Interrupts are of two types, Hardware Interrupts and Software Interrupts.

System Call

A System call is invoked by a software interrupt that transfers the control to the Kernel.  A System call is executed by a Kernel and uses a CPU instruction to execute more privileged code.

Interrupt Vector

This is an area of memory that contains an array of the addresses of the interrupt service routines that correspond to a specific interrupt number.

Command Interpretation

The Operating System contains a command interpreter that accepts and interprets a command from the user and executes the same.  The command interpreter of MS DOS Operating System is contained in the command.com file.  In MS DOS it is also possible to specify a different command interpreter other than command.com; in such a case the name of the command interpreter needs to be mentioned in the config.sys file.

Conclusion

Most of us are unaware of the core concepts of Operating System. This article highlights the core concepts of Operating Systems and the most important terminologies related to it.  Please post your comments and suggestions.  Happy reading!


Product Spotlight
Product Spotlight 

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-29 3:06:37 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search