Given a bash script that runs an infinite loop such as:
do forever:
get data
print data
sleep 1
done
I was wondering if I could avoid the overhead of starting and
terminating the sleep child process by using a different strategy.
All I need to do is ask the kernel not to dispatch the process running
my script for a second or so.
Instead of that, I'm having the kernel go through the motions of
creating an address space (whose only purpose is to "sleep" - i.e. do
nothing for one second) - and then terminate this address space.
Isn't that a rather disproportionate use of resources relative to what I
want to do?
Isn't there a way I could do this via a system call that would probably
be orders of magnitude faster and less resource-hungry?
Or am I barking the wrong tree?
Thanks
CJ