Tuesday, July 5, 2011

Computer Program

What is a computer program?
Programs are a series of instructions to the computer. When a software programmer (a person who writes programs to run on a computer system) develops a program, it is converted into a long list of instructions that is executed by the computer system. In operating systems we talk more of a process (part of a program that is in some stage of execution) than a program. This is because in modern operating systems, only a portion of a program is loaded at any one time. The rest of the program sits waiting on a disk unit till it is needed. This saves memory space.
Processors execute computer programs. A processor is a chip in the computer that executes program instructions. Processors execute millions of instructions per second.

How do operating systems run more than one program at once?
Some systems run only a single process at a time, other systems run multiple processes at once. Most computer systems are single processor based, and a processor can only execute one instruction at a time, so how is it possible for such a single processor system run multiple processes? The simple answer is that it doesn’t. The processor of the computer runs one process for a short period of time, then is switched to the next process and so on. As the processor executes millions of instructions per second, this gives the appearance of many processes running at once.

What is co-operative and preemptive switching?
In a computer system that supports more than one process at once, some mechanism must be used to switch from one task to another. There are two main methods used to perform this switching.
  • Co-operative switching means that a task that is currently running will voluntarily give up the processor at some time, allowing other processes to run.
  • Preemptive switching means that a running task will be interrupted (forced to give up) and the processor given to another waiting process.
The problem with co-operative switching is one process could hang and thus deny execution of other processes, resulting in no work being done. An example of a co-operative system was Windows 3.1
Pre-emptive scheduling is better. It gives more response to all processes and helps prevent (or reduce the number of occurrences of) the dreaded machine lockup. Windows NT workstation is an example of such as operating system.
Note: Only 32-bit programs in Windows 95 are pre-emptive switched. 16-bit programs are still co-operatively switched, which means it is still easy for a 16-bit program to lock up a Windows 95 computer.

A multi-user operating system allows more than one user to share the same computer system at the same time. It does this by time-slicing the computer processor at regular intervals between the various programs run by each user. In this example, there are five people that share the processor hardware and main memory on a time basis. Consider a 486 Intel processor running at 50MHz. This processor is capable of about 6 million instructions per second.
If we decided that we would share the hardware by letting each user run for 1/5th of a second, this would mean each user could execute about 1.2 million instructions each time they have the processor.
We start off by giving the first user (which we will call Bart) the processor hardware, and run Barts program for 1/5th of a second. When the time is up, we intervene, save Barts program state (program code and data) and then start running the second user program (for 1/5th of a second).
This process continues till we eventually get back to user Bart. To continue running Bart's program, we restore the programs code and data and then run for 1/5th of a second.

No comments:

Post a Comment

This is Good Computer Information Blog.they will give
best information about computer.