Time-sharing means sharing of computing resources among many users (processes) by means of multiprogramming and multitasking. By allowing a large number of users to interact concurrently, time-sharing dramatically lowered the cost of providing computing capability.
Many operating system including Windows, Linux and many others provides time-sharing mechanism to different processes.
Here, our task is to show that Linux provides time-sharing mechanism using a simple program.
Approach : Here, two process (parent and child) is created using fork() system call having some print statement in loop. In output we will see that print statement of these two process will execute alternatively showing time-sharing mechanism between two processes.
In the below screenshot, we can see that both print statement is executing concurrently and not one after completion of other.
This article is contributed by Aditya Kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Environment Variables in Linux/Unix
- How to find time taken by a command/program on Linux Shell?
- time command in Linux with examples
- Useful and time saving bash commands in Linux
- C program for pipe in Linux
- A Shell program To Find The GCD | Linux
- Linux Kernel Module Programming: Hello World Program
- Zombie Processes and their Prevention
- Using fork() to produce 1 parent and its 3 child processes
- Chat application between two processes using signals and shared memory
- Linux Virtualization : Linux Containers (lxc)
- du Command in LINUX
- Wikit in Linux
- Some useful Linux Hacks
- Permissions in Linux