The task is to create timer without using any graphics or animation. The timer will be made using system calls whereever necessary. Timer in this context means a stopwatch with up-counting of time.
The timer is created in Linux. Following system calls of Linux are used:
sleep() : It will make the program sleep for number of seconds provided as arguments to the function.
system() : It is used to execute a system command by passing the command as argument to this function.
Below is the implementation for creating timer using System Calls:
Note: This can be made to run on Windows with a bit of modifications.
1. Use “cls” in place of “clear” in system() call.
2. Use ‘S’ in sleep() function in place of lower case ‘s’ in sleep() function.
3. Include windows.h header file.
Making these changes code should run perfectly fine on Windows.
- Computer Network | Algorithm for Dynamic Time out timer Calculation
- Find array with k number of merge sort calls
- Allocating kernel memory (buddy system and slab system)
- system() in C/C++
- C/C++ program to shutdown a system
- Amazing stuff with system() in C / C++
- Print system time in C++ (3 different ways)
- proc file system in Linux
- Users in Linux System Administration
- Groups in Linux System Administration
- Operating System | The Linux Kernel
- dup() and dup2() Linux system call
- SAR command in Linux to monitor system performance
- Software Engineering | System configuration management
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.