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.
- 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++
- Amazing stuff with system() in C / C++
- What is Linux System Administration?
- C/C++ program to shutdown a system
- Introduction to UNIX System
- proc file system in Linux
- Groups in Linux System Administration
- Users in Linux System Administration
- dup() and dup2() Linux system call
- Print system time in C++ (3 different ways)
- SAR command in Linux to monitor system performance
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.