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.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Perl | Tail Calls in Function Recursion
- Find array with k number of merge sort calls
- Algorithm for Dynamic Time out timer Calculation
- Allocating kernel memory (buddy system and slab system)
- system() in C/C++
- Introduction to UNIX System
- C/C++ program to shutdown a system
- Amazing stuff with system() in C / C++
- What is Linux System Administration?
- Groups in Linux System Administration
- Users in Linux System Administration
- Advantages of Database Management System
- Principle of Information System Security
- Conditions for Deadlock in Operating System