Sunteți pe pagina 1din 6

02745022

Rennie Ramlochan
INFO 3400:Fundamentals Of Operating Systems
[1]
An Operating System (OS) is an interface between hardware and user which is responsible
for the management and coordination of activities and the sharing of the resources of the
computer that acts as a host for computing applications run on the machine. As a host, one of the
purposes of an operating system is to handle the details of the operation of the hardware. This
relieves application programs from having to manage these details and makes it easier to write
applications. An operating system performs these services for applications:

In a multitasking operating system where multiple programs can be running at the same
time, the operating system determines which applications should run in what order and
how much time should be allowed for each application before giving another application
a turn.
It manages the sharing of internal memory among multiple applications.

It handles input and output to and from attached hardware devices, such as hard disks,
printers, and dial-up ports.

It sends messages to each application or interactive user (or to a system operator) about
the status of operation and any errors that may have occurred.

It can offload the management of what are called batch jobs (for example, printing) so
that the initiating application is freed from this work.

On computers that can provide parallel processing, an operating system can manage how
to divide the program so that it runs on more than one processor at a time.

Operating systems can be classified as follows:


multi-user : Allows two or more users to run programs at the same time. Some
operating systems permit hundreds or even thousands of concurrent users.
multiprocessing : Supports running a program on more than one CPU.
multitasking : Allows more than one program to run concurrently.
multithreading : Allows different parts of a single program to run concurrently.
real time: Responds to input instantly. General-purpose operating systems, such as
DOS and UNIX, are not real-time.

The most important program that runs on a computer. Operating systems provide a
software platform on top of which other programs, called application programs, can run. The
application program must be written to run on top of a particular operating system. Your choice
of operating system, therefore, determines to a great extent the applications
you can runEvery general-purpose computer must have an operating system to run other
programs.
Operating systems perform basic tasks, such as recognizing input from the keyboard,
sending output to the display screen, keeping track of files and directories on the disk, and
controlling peripheral devices such as disk drives and printers.
For large systems, the operating system has even greater responsibilities and powers. It is
like a traffic cop -- it makes sure that different programs and users running at the same time do
not interfere with each other. The operating system is also responsible for security, ensuring that
unauthorized users do not access the system.
For PCs, the most popular operating systems are DOS, OS/2, and Windows, but others are
available, such as Linux.

[1B] Difference between a process and a program?


A process is a program in execution while a program is a series of instructions to perform
a particular task. In addition a Process is an active entity whereas a Program is a passive entity.
Also, a program is stored in secondary storage, but a process is stored in memory.
A process is usually defined as an instance of a running Program and consists of two
components:
1) A kernel object that the operating system uses to manage the process. The kernel object is also
where the system keeps statistical information about the process.
2) An address space that contains all the executable or DLL module's code and data. It also
contains dynamic memory allocations such as thread stacks and heap allocations.
Processes are separate executable, loadable modules that runs concurrently with other
executable modules. For example, in a multi-tasking environment that supports processes, like
OS/2, a word processor, an internet browser, and a data base, are separate processes and can run
concurrently.
While a program is, it is a set of instructions for a computer that lets the computer
perform a specific task. Before come into execution they must be converted in binary codes
which should be understood by the Operating System. Programs that perform tasks directly
relating to what a person would want to do (such as word processors, spreadsheets, etc.) are
called application software, to distinguish them from system software.

[1C]
Process scheduling is the process of managing several processes which want to access CPU.
There are three forms of queues in an operating. Below is a list of the most common
types of queues and their purpose.

Job queue A set of all processes in the system.Each entering process goes into job
queue. Processes in job queue reside on mass storage and awaits the allocation of
main memory.

Ready queue set of all processes residing in main memory,ready and waiting to
execute,that is the set of all processes that are in main memory and are waiting for
CPU time, are kept in ready queue. Each process is represented by a PCB, and the
PCBs can be linked together to form a ready queue.

Device queues set of processes waiting for an I/O device. When a process is
allowed to use CPU, then that process executes for some time and eventually quits, or
it waits for a particular event to occur, such as the completion of an I/O request. In the
case of I/O request, a request may be a shared device, such as a disk. If I/O requests
of other processes are using disk then the process have to wait for the disk become
available. Process waiting for a particular I/O device is called a device queue.

[1D]
A context switch (also sometimes referred to as a process switch or a task switch) is the
switching of the CPU (central processing unit) from one process or thread to another.
OR
A context switch is sometimes described as the kernel suspending execution of one
process on the CPU and resuming execution of some other process that had previously been
suspended. Context switching can be described in slightly more detail as the kernel (i.e. the core
of the operating system) performing the following activities with regard to processes (including
threads) on the CPU:
(1) suspending the progression of one process and storing the CPU's state (i.e., the
context) for that process somewhere in memory,
(2) retrieving the context of the next process from memory and restoring it in the CPU's
registers and
(3) returning to the location indicated by the program counter (i.e., returning to the line
of code at which the process was interrupted) in order to resume the process.

Context Switching: Steps


In a context switch, the state of the first process must be saved somehow, so that, when
the scheduler gets back to the execution of the first process, it can restore this state and continue.
The state of the process includes all the registers that the process may be using, especially
the program counter, plus any other operating system specific data that may be necessary. This
data is usually stored in a data structure called a process control block (PCB), or switchframe.
Now, in order to switch processes, the PCB for the first process must be created and
saved. The PCBs are sometimes stored upon a per-process stack in kernel memory (as opposed
to the user-mode stack), or there may be some specific operating system defined data structure
for this information.
Since the operating system has effectively suspended the execution of the first process, it
can now load the PCB and context of the second process. In doing so, the program counter from
the PCB is loaded, and thus execution can continue in the new process. New processes are
chosen from a queue or queues. Process and thread priority can influence which process
continues execution, with processes of the highest priority checked first for ready threads to
execute.

[2]
[2a]
P1
0
26

P3
9

P2

P4

P5
14

10
45

34

P6

P8
18

P7
25

[2b]
P1
0
34

P2
2
45

P3

P2
5

P4
7

P1
11

P5
17

P7

P8

P6
19

P5
20

P8
26

P7

[2c]
P1
0
36

P2
5

P3

P4
9

41

44

P5
10
45

P6
14

19

P1
20

P5
25

P7

P8
30

P9
34

[3]
import java.io.*;
import java.util.*;
public class executeProcessList {
public static void main(String[] args) throws IOException{
for (int i = 0; i < args.length; i++){
String a=args[i];
try{

//error checking

Integer.parseInt(a);
if(a.equals("02745022"))System.out.printf("\nProgram created by: Rennie
Ramlochan\n");
//if data is valid process executed
}
catch(NumberFormatException e){
Process proc = Runtime.getRuntime().exec(args[i]);

}
}

}
}
Example of input used:
C:\Documents and Settings\02745022\Desktop>"C:\Program Files\Java\jdk1.6.0_07\bi
n\java.exe" executeProcessList 807003844 notepad 2547854 regedit freecell 027450
22

References:
http://www.webopedia.com/term/o/operating_system.html
http://www.blurtit.com/q397863.html.
www.about.com
http://www.docstoc.com/docs/12955960/CPU-Scheduling
www.sm.luth.se/csee/courses/smd/149/current/lectures/lecture3.pdf

S-ar putea să vă placă și