What is a process and how does the OS simulate parallel processing?
A process is a program in execution.
The OS runs processes concurrently by interleaving their execution.
What are the different components of the process state?
How do you get the processID and what are the header files needed for this?
include<sys></sys>
The header files needed for this are:
You get the process ID by using the getpid() function
What happens when a parent creates a child process using the fork function?
When the parent creates a child process using the fork function then the child
Why does fork return twice?
Fork returns twice, once for the parent and once for the child.
When it returns for the parent, it returns the process of the child and when it returns for the child, it returns 0.
This can be used to distinguish the parent process from the child process.
What happens when the parent terminates before the child?
When the parent terminates before the child, then the child is assigned to ( or rather adopted lol ) by the init process.
How does the parent know when a child has terminated? ( without waiting )
The parent is notified by the kernel through an asynchronous message known as a signal.
What happens when you call wait inside a parent?
The parent blocks until a child has been terminated.
If there are no children, then wait returns immediately.
What is a zombie process?
This is a process that has finished executed but it has an entry in the process table. The process has terminated but is not waited on by the parent.
What happens when a process is a zombie process?
Why should you be worried about zombie processes?
Too many zombie processes prevent the creation of new processes.
What are the different exit functions to terminate a program?
What does atexit do and what is its prototype?
The different exit functions are:
atexit adds exit handlers to a stack of exit handlers, what does this mean?
This means the exit handler that you want to have executed first should be registered the last, because the last one in will be executed first (LIFO) .
What are environment variables?
These are key value pairs defined in the command shell.
What is the prototype of getenv and what does it do?
char* getenv(char* varname):
This function gets the value of the variable with name varname
How are libraries included inside a program?
The libraries are included inside the user code with the help of the linker file. The linker checks the set of know directories for the library.
What is a static library?
A static libraries are created when the library itself is copied and inserted into the user code. This means that any changes to the libraries requrie relinking of the library.
What are Shared or dynamic Libraries?
These are libraries that are not copied into the executable file but rather is refered to by executables.
If the libraries change then there is no need to relink.
What is dynamic linking?
Link to the libraries during runtime.
Describe a process’ address space.
A process
how does the size of the address space depend on the architecture?
Are all addresses in this range accessible?
2^(the number of bits)
16 bits = 2^16
32 bits = 2^32
Not all addresses in this range are accessible
what is kernel space and how is it different from user space?
Kernel space is the part of virtual address space where kernel processes run on.
User space is the part of the Virtual address space where the normal applications run.
The role of the kernel space is to manage applications running in the user space.
how is a process divided?
A process is divided into memory segments.