Operating System Fundamentals


Process Creation in Unix/Linux



Download 2.34 Mb.
View original pdf
Page24/66
Date06.03.2023
Size2.34 Mb.
#60834
1   ...   20   21   22   23   24   25   26   27   ...   66
OperatingSystemFundamentals
best answers from c, Lesson 2 C# Windows Forms
Process Creation in Unix/Linux
In the Unix (and Linux) operating system, new processes are created by a simple system call named ‗fork()‘. The term fork comes from the description of hitting a fork-in-the-road, in other words a place where a decision has to be made. It is easily shown by this diagram. Suppose a program has the following statements

Operating System Fundamentals
33
Statement_A();
Statement_B();
Statement_C(); Fork
Statement_D();
Statement_E();
Statement_F(); If the fork() call was not included it is easy to see that the program simply executes the statements one at a time. However with the inclusion of the fork() command, things get a bit more interesting. When the system called is made at fork(), the operating system will actually duplicate the current process so that there are now two. This means that the original process will keep running statements D through F, but there will also be another process also running statement D through F. When a Unix program issues the fork() system call, the operating system duplicates the current process exactly and once completed there are now two processes executing that look identical. However, they will be two distinct processes sharing the CPU. Any variables (memory) associated with one process will be different than the memory associated with the other process. Who issues the fork command Most applications that developers write would never use the fork system call unless they were trying to create a program that starts another program. In fact the fork() system call remains a mystery to most software developers, so if you never see it again outside of this text, that would be quite normal. When you are working in the GNOME desktop environment, you select applications from a launch menu. When you finally select OpenOffice Write, guess what happens Yes, GNOME will issue a fork() system call. If you are comfortable with the idea of the
fork() system call, you should now ask the question If GNOME issues the fork() call, why then do we see OpenOffice Write instead of another copy of GNOME. As soon as the new process is created the second process will replace its current executable code with new code from the drive.
Statement_A
Statement_B
Statement_C
Fork()
Statement_D
Statement_D
Statement_E
Statement_E
Statement F
Statement_F

Download 2.34 Mb.

Share with your friends:
1   ...   20   21   22   23   24   25   26   27   ...   66




The database is protected by copyright ©ininet.org 2024
send message

    Main page