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++
- Introduction to UNIX System
- Amazing stuff with system() in C / C++
- C/C++ program to shutdown a system
- What is Linux System Administration?
- Print system time in C++ (3 different ways)
- proc file system in Linux
- Users in Linux System Administration
- Groups in Linux System Administration
- dup() and dup2() Linux system call
- Logical and Physical Address in Operating System
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.