2. INTRODUCTION TO PROCESSES
• A program is a collection of
instructions that tell the computer what
to do to accomplish a specific task.
• A process is a running instance of a
program. It is an active entity since it is
a program that is being executed.
3. PROCESS STATE
• As a process executes, it changes state.
• The state of a process is defined in part
by the current activity of that process.
4. • Each process may be in one of the
following state:
• New – The process is being created.
• Running – Instructions are being
executed.
• Waiting – The process is waiting for
some event to occur.
5. • Ready – The process is waiting to be
assigned to a processor.
• Terminated – The process has finished
execution.
6.
7. PROCESS CONTROL
• An important function of the operating
system is to manage all the processes
that exist within a computer system.
8. PROCESS CONTROL BLOCK
• A data structure called process control
block (PCB) contains the information
about a process.
• Every process has a PCB linked with it.
10. CONTEXT SWITCH
• Context switch is a process wherein the
operating system switches the CPU
from one process to another.
• Interrupts cause the operating system
to change a CPU from its current task
and to run a kernel routine.
11. • When an interrupt occurs, the system
needs to save the current context of
the process currently running on the
CPU so that it can restore that context
when its processing is done, essentially
suspending the process and then
resuming it.
12. • Switching the CPU to another process
requires performing a state save of the
current process and a state restore of a
different process.
14. PROCESS MANAGEMENT
(PROCESSES AND THREADS)
• Process
• When a program start execution, we
call it process.
• When it is not executing, it is called a
program.
• One single program can have multiple
processes associated with it.
15. • Threads
• A thread is the unit of execution within
a process. A process can have
anywhere from just one thread to many
threads.
When a process is executed, it can change from one state to another, and that state is defined by its current activity. It means that what is the process currently doing.
Waiting – if it is waiting for some event to occur.
When the process is created, it is admitted via the NEW state, then go to the ready state. So, what is in the ready state? It is waiting to be assigned in a processor. When it begins execution via a scheduler dispatch, it is now in the running state.
After running in the running state, there are 3 cases that may happen:
It is running and it finished its execution, it now in the terminated state. No interruption happen and no error executed.
There can be an interrupt. Some process with high priority came, and this process was interrupted and goes back to the READY state
When it is running, it needs to wait for an i/o or event wait. Unless that i/o is completed, it goes to the ready state again to be executed.
Process number – refers to process ID, it is the unique number of a process. Every process needs to be represented by a unique ID that will identify that process.
Process state – tells us the particular state to which a process is doing at a particular moment.
Program counter – indicates the address of the next instruction that has to be executed for that particular process.
***When a program is in execution, it is now called process.
CPU registers – refers to the register that is being used by a process.
CPU Scheduling Information – this refers to the processes with high priority. Process with high priority may come first, then others will need to wait for it to be completed.
Memory management information – represents the memory that is being used by the process.
Accounting information – keeps an account of a certain things like the resources being used. Resources can be CPU, time, memory. I/O Status information – represents the input and output devices being used by the processs.
These represents the particular aspect of a process.
If an interrupt or a high priority process came, then the executing process must be stopped that is allowed to cause an interrupt. After this is completed, the process that stopped can proceed executing.
Context switch is relevant because if ever there are interrupts, we will know when to stop and when to resume.
EX: When you are reading a book, then suddenly you’re mother called asking you to do something. Since you’re reading and your mother’s task to you is more important than the one you’re reading, then you will place a bookmark to where you left off. So after doing that task, you can again proceed with reading that book.
Keeping that bookmark is same as with saving the current context
Whenever you want to make a program and you are using high level languages like C++, java, you need to have a compiler so the computer can read it. After that, you have your program converted to binary codes, and it is ready for execution. But it is not enough to execute this. What it have to do first is to be loaded into memory, and for the program to execute it needs resources of the computer system. So what is needed for this to happen? The operating system.
Before, there is only one process per execution. But for today’s computer, multitasking can be done/multiple program can be executed.
Within a process, there can be one or more threads.
In early computer, one process only have one thread.