Showing posts with label Interaction with Operating System. Show all posts
Showing posts with label Interaction with Operating System. Show all posts

Saturday, July 23, 2011

All about Semaphores

A semaphore is a synchronization mechanism that can be used to manage synchronization relationships and implement the access policies. A semaphore is a special kind of variable that can only be accessed by very specific operations. The semaphore is used to help threads and processes synchronize access to shared modifiable memory or manage access to a device or other resource. The semaphore is used as a key to access the resource. This key can only be owned by one process or thread at a time. Whichever task owns the key or semaphore locks the resource for its exclusive use.

Types:
Counting semaphores are used when you might have multiple devices (like 3 printers or multiple memory buffers).

Binary semaphores are used to gain exclusive access to a single resource (like the serial port, a non-reentrant library routine, or a hard disk drive). A counting semaphore that has a maximum value of 1 is equivalent to a binary semaphore (because the semaphore's value can only be 0 or 1.

Mutex semaphores are optimized for use in controlling mutually exclusive access to a resource. There are several implementations of this type of semaphore.

Implementation:
Semaphores can be implemented with a queue and an integer counter. You maintain the set of consumers in the queue, and when a consumer releases the semaphore, you retrieve the next entry in the queue and "wake" them to allow them to enter the critical section. When a consumer requests the semaphore, you simply push them onto the queue. If no one is in the critical section, you go ahead and grant the requester the right to enter the critical section.

Thursday, July 21, 2011

Real Time Operating System

A real time operating system is based on the OS which has the capability to perform a number of functions at a time. This RTOS only serves real-time applications. These real-time applications include robots, spaceships; research tools used by scientists and embedded systems like home appliances, cell phones and thermostat.

RTOS system captures the real time events and brings out the results which may slightly differ from the reality. It’s processing and computation totally depends on the way it is programmed. RTOS can be judged as how quickly it performs the operation and how accurate the results are. Most important factors which increase the working of this system are low interrupt latency and a low thread switching latency.

The real time operating system is designed keeping in mind every aspect in mind of real life. This operating system is designed on two basic principles. First design pattern is that it should focus on event-driven programming so that tasks can process depending upon their scheduling priorities. Second design refers to time sharing feature so to process tasks on the basis of clock interrupts.

In RTOS allocation of memory is the most critical task. Two elements are of significant importance in case of memory allocation. First one is speed and second is the fragmentation of free region during the memory allocation process.

Thursday, June 17, 2010

Firmware

Fixed software programs that internally control various electronic devices or individual hardware parts of these devices (such as mobile phones). They involved very basic low-level operations of the device, without which the device would be completely non-functional.More simple firmwares are usually stored on ROM or OTP/PROM, while more complex firmwares occupy flash memory to allow for updates. Common reasons for updating firmware include fixing bugs or adding features to the device.Doing so usually involves loading a binary image file provided by the manufacturer into the device, according to a specific procedure. More often than not this is meant to be done by the end user.

Tuesday, April 13, 2010

Understand what daemon is???

A demon (also see daemon which has a somewhat similar meaning) is a program or process, part of a larger program or process, that is dormant until a certain condition occurs and then is initiated to do its processing. Eric Raymond cites an artificial intelligence ( artificial intelligence ) application as an example. An AI program might include a number of demons, one or more of which might become active when a new piece of knowledge was acquired by the AI program. If the new knowledge affected a particular demon's own sphere of knowledge, it would spring into action and create new pieces of knowledge based on its particular inference rules. Each of these new pieces of knowledge might in turn activate additional demons that would continue to filter through and refine the entire AI knowledge base.

Sunday, February 22, 2009

Operating System Structure Part-2

In the last post we had seen the first method in which an operating system can be structured i.e Simple Structure.From the last post about simple structure it is very much clear that this method is not very much efficient and there may be other structuring techniques that are much more efficient than simple structure technique.The most important thing for the success of any operating system structure is its hardware support,if an operating system got the proper hardware support then it can be broken into pieces that are more smaller and more effective then that of simple structure.If this is done successfully then an operating system can have much more control over the computer and the applications that are used by computers.In this post we take a look at the other method of making an operating system more modular i.e Layered Approach.

Layered Approach:-In this method of structuring the whole operating system is divided into a number of layers,in which the lowest layer represents the hardware part and the highest layer represents its user interface part.Each layer in this model is an implementation of abstract object model that contains objects and the routines that are required to access these objects.In layered approach a layer can only invoked the operations of its lower level layers.This approach helps very much in simplifying debugging and system verification.The first layer can be debugged without any concern for the rest of the system because their is no layer below the first layer and underlying hardware are assumed to be functioned correctly.Once the first layer is debugged,we can assume its correct functioning and we can debugged the second layer and so on.If an error is found during debugging of that layer then that error belongs to that particular layer because all the underlying layer are already debugged.Thus, the design and implementation of the system is simplified.
The main problem that exists with the layered approach is in defining the functions of every layer because a layer can only use its lower level layers for its functioning.One more problem that exists with this layered approach is that they tend to be less efficient than other types.For instance consider an example,when an user program executes an I/O operation,it executes a system call that is trapped to the I/O layer,which then call the memory management layer,which in turn call the CPU scheduling layer and then passes to the hardware.In this whole process,the each layer add its corresponding overhead result in that system call takes more time in comparison to the non-layered approach.

Saturday, February 21, 2009

Operating System Structure Part-1

If a system is large as well as complex then it is required that it must be designed carefully so that it can function properly and can be modified easily.The most common approach to achieve this is to partition the whole system into small components rather than having a single big structure.Now there are four approaches for achieving this.In this post we take a look at the first approach for structuring the system i.e Simple Structure.

Simple Structure:As all we know that every commercial system do not have well defined structure,the main reason behind this is,initially when these system are developed they developed as a simple,small,having limited functionality and then with time they started to grew up beyond their scope.The most common example of such type of a commercial system is MS-DOS.Initially when it was written the designers of DOS have no idea that this operating system became so popular in future.The main aim of designing this MS-DOS is to provide each and every functionality in a very limited space.So,in achieving this it was not divided into modules carefully.

In MS-DOS,the interfaces and level of functionality are not well separated.The major drawback of this thing is that application programs are able to access the basic I/O routines that means they can directly read or write to the basic display and disk drives.Due to this problem,the MS-DOS is very much vulnerable to the malicious programs,causing entire system crashes on the failing of user program.The other major problem with MS-DOS is that it is limited to hardware of its era because at that time the Intel 8088 for which it was written provides no dual mode and no hardware protection.Hence,in short we can say that their exists a lot of problem with this simple structure.

Friday, January 23, 2009

Avoid Swapping of Files

When Windows loads, it moves certain parts of the operating system to the swap file anyway, regardless of whether it has run out of RAM or not. This is very good for systems with less memory, since it leaves some free RAM and applications will start much faster. Otherwise, when you start an application and memory is required, Windows will have to first move all this data to the swap file to free up RAM. This functionality is usually not required on systems with 256 MB or more RAM, especially if they only run common productivity tools such as Office and Internet applications. You can prevent Windows from using the swap file until absolutely required by adding the line below to the [386Enh] section of the \Windows\ system.ini file.

ConservativeSwapfile Usage=1 You can edit this file in Notepad. In case you face any problems such as programs crashing frequently, remove this line and reboot.

Sunday, October 19, 2008

Role of Timer in Operating System

Timer in Operating System:As all we know that it is only the operating system that has full control over the CPU,and it is the primary duty of operating system to prevent user programs from getting stuck into an infinite loop or not calling to system services and never returning control back to the operating system.To accomplish all those services an operating system uses a device known as Timer.The main task of a timer is to interrupt the CPU after a specific period of time.This specific period of time is set by operating system and its value may very from 1 ms to 1 second.If the operating system is interested in using variable timer then it is implemented with the help of fixed rate clock or counter and in this case operating system sets the counter.

Working of Timer:Whenever the clock ticks,the counter is decremented.When the value of this counter reaches zero an interrupt occurs and control is transferred back to the operating system.Let's understand this with the help of example,A 10 bit counter with a 1 Millisecond clock allows interrupts at interval from 1 millisecond to 1024 milliseconds,in steps of 1 millisecond.Before turning control over to the user process an operating system ensures that timer is set to interrupt.Hence a timer can be used to prevent a user program from running too long.We can also initialize the value of counter with the amount of time that a process requires to complete its execution.For example,a program with 7 minutes time limit has its counter initialized to 420,and for every clock tick the counter is decremented by 1.Hence after 420 ticks the control is automatically transferred back to the operating system.

Tuesday, October 7, 2008

User Operating System Interface Part-2

Hello friends in the last post i told you about the one way command line interface through which an user can interact with the operating system.Now in this post i am going to told you about the second way through which an user can interact with the operating system.

The second approach through which an user can interface with the operating system is through Graphical User Interface(GUI).This interface provides a mouse based window and menu system as an interface to the user,rather than entering commands through command line interface.A GUI provides a desktop metaphor where the mouse is moved to position its pointer on images,or icons,on the screen(desktop) that represent programs,files,directories and system functions.Depending on the mouse pointer location,clicking a button can invoke a program,select file or directory which is known as folder.Microsoft's first version of Windows version 1.0 was based upon a GUI interface to the MS-DOS operating system.Then after this various versions of windows systems proceeding its initial version had been developed Windows 98,Windows 2000,Windows XP and Windows Vista.

The choice of whether to use a command line or GUI interface is mostly depend on individual to individual.As a very general rule,many UNIX users prefer a command line interface because they provide powerful shell interfaces.Alternatively, most Windows users are pleased to use the Windows GUI environment and almost never use the MS-DOS shell interfaces.

Sunday, October 5, 2008

User Operating System Interface

Hello friends in this post i am going to told you about the ways through which an user can interact with the operating system.

There exists two fundamental approaches through which an user can interact with the operating system.First technique is command line interface or command interpreter with the help of which an user can directly enter commands and further these commands are executed by operating system.The second approach is GUI(Graphical User Interface) in which user gets graphical interface to interact with the operating system.Now first begins with command line interface.

Command Line Interface: The main function of the command interpreter is to get and execute the next user-specified command.Many of the commands given at this level manipulate files:create,delete,list,print,copy and so on.The MS_DOS and UNIX shell operate in this way.Now here also exists two ways in which these commands can be implemented.

The first approach implies that, the command interpreter itself contains the code to execute command.For ex: suppose we entered the command 'delete' to delete a file,then in this case the command interpreter jump to a section of code that sets up the appropriate parameter and sets the appropriate system call.The summary of this method is that command interpreter has itself its code for executing the command.

In the second approach whenever users enter any command the command interpreter did not understand the command in any way,what it does, it merely used the command to identify a file to be loaded into memory and executed.This approach is used in UNIX operating system.Thus the UNIX command to create a file is create file.txt. Now the UNIX operating system search for the file create,load the file into memory,and execute it with the parameter file.txt.The function that is associated with the create command would be defined completely by the code in the file create.With the help of this approach an user can add new commands to the system by creating new files with the proper names.