Explain the generic first steps the kernel needs to do to co

Explain the generic first steps the kernel needs to do to convert a program into a process. (Draw relevant figures). Explain the various sections of the memory that is assigned to a process by the kernel.

Solution

Kernel needs to do load a image of executable file in memory

First when we run or execute the program the it will create on executable file which one is loading and managing by kernel. To load a program, an operating system loader loads the file into memory. The loader must be know the type of file (it must be understandable for operating system) like resources and debug information.

The image of the executable file in memory is machine. Image means a “snapshot” of what is in memory. It may be array of bytes can be machine code, data, or neither – we know only program instructions know.

The kernel needs to be able to load the file from disk into memory somewhere in order to execute it. Kernel load the file as it into memory. The kernel or another program can get any useful data from the program file. Loaded file will be machine understandable, So machine can do the operation according the program.

Various sections of the memory that is assigned to a process by the kernel :

Code section: Its contain the executable files Which can’t be change. Executable files include four canonical sections called, by convention, .text, .data, .rodata, and .bss. It is machine understandable code. Code section memory is assign when we execute the program. Its contain only code. Code section also know as text segment or text section.

Data section: It is a portion of an object file or we can say virtual address space of a program. Its contains initialized static variables, , global variables and static local variables. Data section size is determined by the size of source code. We can’t change at run time.

The data segment or section in two categories:

    initialized data : like int i =10; char c=’a’;

    Uninitialized data: int a; char c;

For this allocation of memory at time of declaration.

Stack: Stack is important part of memory , its considered as part of the data section of a process and It is involved in the execution of any program. A stack is generic data structure , It performing two operation push and pop for data inserting and deleting from memory. Stack memory will deleted after completion of program.

Stacks an area of memory which contains the address to return of function, the input arguments to the function and local variables.

Heap: The heap is an area of memory which is allocated at run time we can say dynamic memory allocation . The bottom of the heap is known as the brk. The use the brk call to grow the area of memory downwards the process can request the kernel allocate more memory for it to use. The heap is managed by library function malloc, calloc, realloc, free .

malloca and calloc : use for memory allocation.

realloc : use for memory reallocation.

free: use for free or delete the allocated memory.

Explain the generic first steps the kernel needs to do to convert a program into a process. (Draw relevant figures). Explain the various sections of the memory

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site