I am writing small debugging program for multithread apps. My idea is to run the target, that is being debuged for for example 100 nanosecs, then pause and examine its memory. However this ( just pseudocode )
nanosleep(100); //sleep debuger for 100 nanosec and let a program run
kill(target_app_pid, SIGSTOP); //stop target app
wouldn't work, because process-switch could happen right after nanosleep and target would run longer as required. Is there any way in to give a process "defined" time slice and then suspend it? Only solution that I can imagine is add system calls and fix the scheduler to achieve what I require but this assumes great effort and many bugs. Perhaps setting "real-time" priority for debuger process can help? Would it be clean solution?
Assume too, that I can insrument source code of target app. Is it possible to set up some kind of timer and sleep the whole process after some (very small and precise) period of time?