now i don't know if it's the best way of doing this, but measuring the difference between a process' cpu time and wall time could be used to measure io boundedness of that process. (given that the CPU is not overloaded, so the amount of time the process spends in the ready queue is negligible compared to the amount of time that it stays in the waiting queue.
That's a nice topic to research about. There are many instances where processes are slow due to IO operations and finding that out is quite useful. I might even make a video on this
On Linux, it's a good choice since it simply calls clock_gettime with the CPUTIME constant. On Windows it returns the wall clock and recommends us using what I showed in the video (learn.microsoft.com/en-us/cpp/c-runtime-library/reference/clock?view=msvc-170). Not sure about other platforms. I found it in my research and decided to not show it as it causes more confusion.
There is this video on the topic: code-vault.net/lesson/931c1634bae351f1ec660773c5001a5b Although it does use some standard functions. I noted down your question, maybe I will do a video on that if it's not too difficult (working with date and time is often complicated)
now i don't know if it's the best way of doing this, but measuring the difference between a process' cpu time and wall time could be used to measure io boundedness of that process. (given that the CPU is not overloaded, so the amount of time the process spends in the ready queue is negligible compared to the amount of time that it stays in the waiting queue.
That's a nice topic to research about. There are many instances where processes are slow due to IO operations and finding that out is quite useful. I might even make a video on this
Oh you are back ! How exciting ;)
and what are you think about clock() function? In manual says "clock - determine processor time". Does it correct to use for measurement or not?
On Linux, it's a good choice since it simply calls clock_gettime with the CPUTIME constant. On Windows it returns the wall clock and recommends us using what I showed in the video (learn.microsoft.com/en-us/cpp/c-runtime-library/reference/clock?view=msvc-170). Not sure about other platforms. I found it in my research and decided to not show it as it causes more confusion.
@@CodeVault Thank you
can you please create a video on EPOCH time, how to convert epoch time (in seconds) to actual time without using any inbuilt functions in c ?
There is this video on the topic: code-vault.net/lesson/931c1634bae351f1ec660773c5001a5b
Although it does use some standard functions. I noted down your question, maybe I will do a video on that if it's not too difficult (working with date and time is often complicated)
@@CodeVault Thank you for your awesome videos
great video!
Where can I get this compiler sir ? How can I install it. Please reply back the link. Tq
gcc gcc.gnu.org/ can be found on most Linux distros and, for Windows I am just using MSVC in Visual Studio visualstudio.microsoft.com/
My question is different from this topic...
Can we find the maximum number of thread that we can create in a program?
To find out you can simply use this command: cat /proc/sys/kernel/threads-max
Would the compiler not be clever enough to optimise out any operations done on x, if it’s never read from? (Or does that require an optimisation flag)
Yes, it does optimize it away but only with -O2. By default it should be left alone
@@CodeVault ahh, makes sense.
Is this CPU time equal to sys or user time when measuring with time function in shell?
In shell the time command is explained here: linux.die.net/man/1/time
You do get real time and CPU user time