How do you force Jitter into the Scheduler? Testing multithreaded programs.
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How do you force Jitter into the Scheduler? Testing multithreaded programs.
So somebody has inflicted a multithreaded unit test on us. (Yes, yes, I Know, that's A Very Bad Idea).
Now this damn thing is flaky.
It fails sometimes.
I'd like to run it a thousand times with the linux scheduler making subtly different choices about scheduling the various threads in each run to see if I can get it to fail more often.... and hence find and fix the issue.
You have a "race condition," therefore a poorly-designed program. A well-designed multiprocess/multithread program must make no assumptions as to timing. It must run correctly, no matter what the Linux scheduling settings might be. You cannot "fix the issue" without redesigning the program. Sorry . . .
However, the first step to fixing it is to be able to instrument it more closely and trigger the fault again...
Alas, the fault only triggers on in fifty or so times.
Thus the question wasn't "Why is it flaky?" I know why.
The question is, "How can I get the Linux Scheduler to stop behaving like the lovely Best of Breed scheduler it is.... and start behaving like a malicious monster that will deliberately and with intent shuffle the scheduling and timing of the threads to expose the flaw?"
Thread-sync problems are always flaky, and the only way I know of to deal with them is by desk-checking the application logic. For example, a shared data-structure that isn't protected by a mutex in every case. When you do successfully use a debugger, you often wind up looking at where the flaming wreckage landed, not the point at which the bomb actually went off in the cockpit.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.