Operating System:Process Management
Process Management
• A process is a program in execution. For example, when we write a program in C or C++ and compile it, the compiler creates binary code. The original code and binary code are both programs.
• When we actually run the binary code, it becomes a process.
• A process is an ‘active’ entity, as opposed to a program, which is considered to be a ‘passive’ entity.
Prg from Secd-Mem-> RAM -> Processor 1.User Process : Run by user
2. System Process : Run by O.S
What does a process look like in memory?
Stack: The process Stack contains the temporary data such as method/function parameters, return address and local variables. (Fun call itself)
Heap: This is dynamically process during its run time.
allocated memory to a (malloc, calloc)
Text: This includes the current activity represented by the value of Program Counter and the contents of the processor's registers.
Data: This section contains the global and static variables.
Segmentation fault:
When the process to cross the boundary of the process. boundary of the process ( Stack, heap, data,
text) is the total memory area neeed to process the task.
int b=4; ---- Global var
fun1()
{ int a=5; ---local var
a++;
b++;
printf a , b;
}
fun2()
{
static int a=5;
a++, b++;
printf a , b;
}
main()
{
fun1(); fun2(); fun1(); fun2();
}
6,5-6,6-6,7-7,8
out put: fun1(): 6,5 6,6
fun2() 6,7 7,8
fun1()
{ int a=5; ---local var
a++;
b++;
printf a , b;
}
fun2()
{
static int a=5;
a++, b++;
printf a , b;
}
main()
{
fun1(); fun2(); fun1(); fun2();
}
6,5-6,6-6,7-7,8
out put: fun1(): 6,5 6,6
fun2() 6,7 7,8
Process State
1. New: Newly Created Process (or) being-created process.
2. Ready: After creation process moves to Ready state, i.e. the process is ready for execution.
3. Run: Currently running process in CPU (only one process at a time can be under execution in a single processor).
4. Wait (or Block): When a process requests I/O access.
5. Complete (or Terminated): The process completed its execution.
6. Suspended Ready: When the ready queue becomes full, some processes are moved to suspended ready state
7. Suspended Block: When waiting queue becomes full.
• Suspended states are stored in the secondary memory
Process Time (two types)
1. CPU time : Need the time for process the task 2. I/O time: Need the time to process the i/o task
CPU Intensive:
Need more time to process task in cpu than I/O time
I/O Intensive:
Need more time to process i/o than CPU time (help multi-prg)
Easy to understand sir
ReplyDelete