Week#3_Process
Process Definitions
A process is essentially a program in execution. The execution of a process must advance in a successive style.
A process is characterized as a substance which speaks to the fundamental unit of work to be actualized in the framework.To place it in straightforward terms, we compose our PC programs in a book document and when we execute this program, it turns into a process which plays out all the errands referenced in the program.
At the point when a program is stacked into the memory and it turns into a process, it very well may be separated into four areas ─ stack, pile, text and information. The accompanying picture shows a streamlined format of a process inside primary memory
1 Stack
The process Stack contains the impermanent information, for example, strategy/work boundaries, return address and nearby factors.
2 Load
This is progressively distributed memory to a process during its run time.
3 Text
This incorporates the current action spoke to by the estimation of Program Counter and the substance of the processor's registers.
4 Information (Data)
This segment contains the worldwide and static factors.
Strong and weak symbols.
The keyword extern implements external linkage. when we use the extern we tell the linker to look for the defination elsewhere. Its declaration does not take any space.
Program's symbols are of types weak symbols and strong symbols.
Strong symbols
Initialized global variables are strong symbols.
Weak symbols
Uninitialized global variables are weak symbols.
Linker’s symbol rules
Strong symbols with the same name are not allowed.
If there is both weak and strong symbols in object files choose strong symbols.
If there is weak symbol in all the object files then choose the file that takes up the largest space.
The linker can choose an arbitrary one from the multiple weak symbols.
Packaging commonly used functions.
There are two options used by the programmers.
The first option is that the programmer put all the functions in single source program and link big object programs .but it is inefficient in space and time
The second option is to put each function in a separate source file . Efficient in space and time but most of the burden is on the programmer.
Libraries
Automatically linked into your program by gcc.
Provide proper information about usage of functions and variables.
8mb achieve of 900 object files.
I/o ,memory allocation, string handling ,data and time
Libm.a
Math library
1Mb achieved of 226 object files.
Floating point math
Private Address Space
Each process has its own private address space.
The process address space is the set of logical addresses that a process references in its code.
The operating system takes care of mapping the logical addresses to physical addresses at the time of memory allocation to the program. There are three types of addresses used in a program before and after memory is allocated
1 Symbolic addresses
The addresses used in a source code. The variable names, constants, and instruction title are the basic elements of the symbolic address space.
2 Relative addresses
At the time of compilation, a compiler conversion symbolic addresses into relative addresses.
3 Physical addresses
The loader creates these addresses at the time when a program is loaded into main memory.
Virtual and physical addresses are the same in compile-time and load-time address-binding schemes. Virtual and physical addresses differ in execution-time address-binding scheme.
The set of all logical addresses generated by a program is referred to as a logical address space. The set of all physical addresses corresponding to these logical addresses is referred to as a physical address space.
The runtime mapping from virtual to physical address is done by the memory management unit (MMU) which is a hardware device. MMU uses following mechanism to convert virtual address to physical address.
The value in the base register is added to every address generated by a user process, which is treated as offset at the time it is sent to memory. For example, if the base register value is 10000, then an attempt by the user to use address location 100 will be dynamically reallocated to location 10100.
The user program deals with virtual addresses; it never sees the real physical addresses.
Flow Control
The execution order of statements, function calls or instructions is know as control flow.
There are thousand of statements or instructions that wait for their execution or CPU time. But these thousand of statements are not executed at a same time. These statements are executed one by one or in some sequence.
At a time, only one statement will be executed and other statements wait for their turn. All this procedure is said to be flow control.
All the statements are executed by Central Processing Unit. CPU is responsible for execution of statements or instructions.
CPU is busy all the time.
The most important thing for instructions or statements is taking the CPU time for their execution.
Statements are executed at some order.
Some statements are executed at their priority measures. Means that high priority statement executed first than the low priority statements. These priorties are assign according to some values. Those instructions executed first whose values are high. And those instructions executed last whose values are less.