![]() ![]() Background and foreground processesĪs we already discussed that we can start a process by its name in Unix. But we will not go into much detail about it here(refer to the man pages of setuid and setgid for more information on this). An exception to the above rule is where a process can acquire greater privileges than the user who triggered it if the setuid or setgid bit is set for that particular process. For example a process triggered by user who does not have superuser privileges cannot do stuff that require root privileges while a process triggered by root can do any thing that it is programmed to do. ![]() A process directly inherits all the privileges of the user who has triggered this process. One of the most important control information for a process is the privileges. Its priority and other control information.Usually the vector containing the command line information is stored here and then the address of this vector of information and number of elements in vector is copied to ‘argv’ and ‘argc’ (the two arguments to ‘main()’ function).īesides the above information, a process also contains information like Command line arguments and environment variablesĪ process also contains room for storing environment variables and the command line arguments that we pass to the program. This is the reason why C programmers worry a lot about memory leaks which are caused on heap segment and may affect other processes on the system. Heap segment is not local to a process but shared across processes. This memory for this data is allocated on runtime on heap segment. Then there is data which is stored on heap. In case of recursive function an independent stack for each function call exists. ![]() A function which is called allocates memory for its local variables and temporary variables on stack itself. Stack also contains information about the callers environment, like some of the machine registers are also stored on stack. ![]() Stack is particular to a function and besides containing the information about local variables it also contains information about the address where the flow will return once the execution of function is done. Local variables which are local to functions are stored on stack. Also, static variables are stored in data segment. As the name suggest, initialized data segment contains those global variables which are initialized before hand while uninitialized data segment (also known as ‘BSS’ segment) contains uninitialized global variables. Data segment can be classified into initialized data segment and uninitialized data segment. This segment has read only privileges which means that a program cannot modify its text segment. Usually for programs like text editors which are executed frequently the text segment is shared. Program instructions are kept in text segments which are executed by CPU. A Unix process can be thought of as a container which contains: Program Instructions Now, since we are clear with what exactly a process is, lets dig a bit deeper to see what a process consists of. For effective use of the ps command, refer to 7 Practical PS Command Examples for Process Monitoring. So we say that a process is a “running instance” of a program.Īs you already know, you can use ps command to view the processes running on your system. Suppose we run a program simultaneously 5 times, then corresponding to each instance there will be a process running in the system. In this article we used two terms ‘program’ and ‘running instance’. A process is a running instance of a program. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |