Question

Operating System Review Q uestion: part a.) Explain the concept of a process and distinguish its differences from a program. part b.) Describe the difference between a mode switch and a process switch.

1 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

A process is basically a program in execution. The execution of a process must progress in a sequential fashion.

A process is defined as an entity which represents the basic unit of work to be implemented in the system.

To put it in simple terms, we write our computer programs in a text file and when we execute this program, it becomes a process which performs all the tasks mentioned in the program.

BASIS FOR PROGRAM PROCESS COMPARISON Program is a set of instruction. When a program is executed, it is known as process Active Basic Nature Passive Lifespan Longer Process holds resources such as CPU, memory address, disk, I/O etc. Required Program is stored on disk in some file and does not require any other resources. resources

A Program, in simple words, can be considered as a system activity. In batch processing system these are called executing jobs while in a real-time operating system it is called tasks or programs. A user can run multiple programs where the operating system facilitates its own internal programmed activities such as memory management using some techniques.

A program is a passive entity, for example, a file accommodating a group of instructions to be executed (executable file). It is so called because it doesn’t perform any action by itself, it has to be executed to realize the actions specified in it.

The address space of a program is composed of the instruction, data and stack. Assume P is the program we are writing, to realize execution of P, the operating system allocates memory to accommodate P’s address space.

It schedules P for execution and also sets up an arrangement through which p can access file info. The CPU is shown in the dashed box because it is not always executing instructions of P; in fact, OS shares the CPU between the execution of P and executions of other programs.

A Process is an execution of a program. It is considered as an active entity and realizes the actions specified in a program. Multiple processes can be related to the same program. It handles the operating system activities through PCB (Process control Block) which includes program counter, stack, state etc. Program counter stores the next sequence of instruction that is to be executed later.

It needs resources like processing, memory and I/O resources to accomplish management tasks. During the execution of a program, it could engage processor or I/O operation that makes a process different from a program.

Let us understand this from an example; we are writing a C program. While writing and storing a program in a file, it is just a script and does not perform any action, but when it is executed it turns into process hence process is dynamic in nature. Sharing of resources among multiple processes is employed by current machines, but in actual a single processor is distributed among several processes.

Key Differences Between Program and Process

  1. A program is a definite group of ordered operations that are to be performed. On the other hand, an instance of a program being executed is a process.
  2. The nature of the program is passive as it does nothing until it gets executed whereas a process is dynamic or active in nature as it is an instance of executing program and perform the specific action.
  3. A program has a longer lifespan because it is stored in the memory until it is not manually deleted while a process has a shorter and limited lifespan because it gets terminated after the completion of the task.
  4. The resource requirement is much higher in case of a process; it could need processing, memory, I/O resources for the successful execution. In contrast, a program just requires memory for storage.

2. A process switch(AKA context switch) is what it is called when the processor switches from one thread/process to another. This causes the contents of the cpu registers and instruction pointer to be saved. The registers and instruction pointer for the new task will then be loaded into the processor and execution of the new process will start/resume. The old program is no longer executing, but it's state is saved in memory for when the kernel decides that it is ready to execute it again. This is what gives the illusion of multitasking, while in reality, only a single process can run at a time on a cpu. A context switch can occur by hardware or software. A hardware interrupt can occur from a device such as the keyboard,mouse,or system timer, causing code to begin executing the interrupt code. Software switches are occurred as a result of the kernel manually performing a task switch. This is how the scheduler usually makes a context switch.

A mode switch is what is referred to when the cpu changes privilege levels. The kernel works at a higher privilege than a standard user task. In order for the user task to access things controlled by the kernel, it is necessary fro a mode switch to occur. The currently executing process does NOT change during a mode switch. The processor uses these modes(aka rings) to protect the OS from misbehaving or malicious programs, as well as controlling concurrent access to ram, io devices,etc. A mode switch must occur for a software context switch to occur. Only the Kernel can cause a context switch.
Note: The idea of a general protection fault is that a user application has tried to do something that it isn't allowed to do, such as accessing certain parts of it's address space that is not accessible to it.

Add a comment
Know the answer?
Add Answer to:
Operating System Review Q uestion: part a.) Explain the concept of a process and distinguish its...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT