0% found this document useful (0 votes)
52 views

Operating Systems - CS550 Class Notes For Week1

Processes are important entities for an operating system to execute programs. A process has memory components like the heap and stack. The stack is static memory allocated by default, while the heap is dynamically allocated using functions like malloc. Processes can be created using the fork system call, which returns a process ID (PID) of 0 for the child and greater than 0 for the parent. There are different states in a process's lifecycle like ready, running, and blocked. The CPU scheduler decides process priority and executes processes based on factors like time to completion. Common commands to examine processes include ps, proc, and top.

Uploaded by

Phani Kiran
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Operating Systems - CS550 Class Notes For Week1

Processes are important entities for an operating system to execute programs. A process has memory components like the heap and stack. The stack is static memory allocated by default, while the heap is dynamically allocated using functions like malloc. Processes can be created using the fork system call, which returns a process ID (PID) of 0 for the child and greater than 0 for the parent. There are different states in a process's lifecycle like ready, running, and blocked. The CPU scheduler decides process priority and executes processes based on factors like time to completion. Common commands to examine processes include ps, proc, and top.

Uploaded by

Phani Kiran
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Operating Systems CS550

Class Notes for week1


Processes are very important for an OS. Operating system mainly work for
processes. So a process can be defined as an entity which executes the instructions
of a program in the corresponding order. One of the main components or the
entities of a process is memory. Memory is of two types heap and stack respectively.
Stack is a type of memory which is created by the system by default or we can also
say it as a static memory. On the other hand, heap is dynamically allocated memory
where a user explicitly creates some memory using in built functions of c like
malloc, calloc etc. In general heap and stack grow towards each other so that there
is no hard limit or blocking of the memory growing. When the process dies all the
memory i.e. created is released back to the operating systems.
Creating a process?
A process can be created using a fork() system call. Usually a process is created
when we perform the following operations
Running a program from the command line
Providing a service
One process starting another process
Technically a process can be created as pid = fork(); This function returns the id of
newly created process. If the pid returned is -1 it implies that there is an error while
creating a process. If there are no errors a PID will be either 0 or a positive integer.
Pid=0 implies a child process where as pid > 0 implies a parent process. Processes
which are at the same level are called siblings or processes which are derived from
a same parent also called siblings. Parent process is also called as an init function
which is the primary method for invoking a process. The process hierarchy is just
like a tree we have in typical data structures.
So far we have discussed on creating a process, now we need to know how this
process are managed or in other words how is the CPU used for running all the
processes. CPU scheduler is the one which decides the process priority. There are 2
main steps in process execution, first is to decide list of processes priority and
second is to execute the processes. There are many factors that are taken into
consideration to decide the process priority viz. time a process takes to complete,
most important process etc. The CPU scheduler is different for different operating
systems, since the algorithm used for selecting a process is different in each OS.
Now a process is selected and is ready to be executed. There are 3 stages in a
process lifecycle viz. Ready, Running and Blocked
Ready State: The state in which a process is ready and waiting for the CPU
scheduler to pick it up.
Running State: The state in which process is currently executing.
Blocked State: The state in which a process is waiting for some event to occur or
currently blocked

Examining Process: Now the processes are running and there are many ways we
can examine a process. Some of the commands which are used in this are ps, /proc,
top etc. Top command gives the result of processes in a sorted order of CPU usage.
When a user wants to execute a command in shell the parent process first creates a
child process and the child process finds the corresponding bin for the entered
command. Now the child process image is replaced by the new program image. This
is done using exec (). But this method is not efficient since we are making 2 calls
here. If in case we have some files open before an exec function call we still have
the files open even after the exec call, OS takes care of this file systems. This is one
nice feature of exec call, not everything in is replaced by new program image.
Wait System Call: Wait system call allows the parent to know the status of the
child and also to know when the child process completes.
Apart from the above two system calls there are some more useful system calls like
sleep, exit etc. Exit call accepts two types of status 0 and 1 where 0 is for normal
status and 1 for any error.
Orphan Process: A child process is said to be an orphan process if it parent
process has died.

You might also like