I need to make sure that from the moment I find the process to when I kill it, no other process has the CPU. Can this be done?
Not as far as I'm aware on say Linux for example. Imagine your process is running and the timer (runs at 100 Hz by default) goes off because your process's time is up. Now the operating system is free to assign the CPU to another process at it's will during one of these ticks (or another hardware interrupt). (Based on the schedule algorithm and they vary.)
Now suppose the operating system were to let processes request to not be interrupted. In that case it's possible one process would keep the CPU forever. Imagine say the process has an infinite loop in it, that bug in a user program could hang the system so nothing else would get the CPU. As far as I know Linux doesn't have any way to let processes request to not be interrupted.
It has been a while since I've looked at the scheduler code (and I hear it has changed) but I recall you could specify priority levels where all processes in a higher priority would be served first. (Note this is different than the "nice" level as I recall.) I'm not sure but you may be able to make your find-and-kill process a higher priority and it won't give up the CPU until it yeilds it by it's own choice.
Update: ie all lower priority processes won't get the CPU unless the higher priority processes (only your one process) have yielded the CPU.
The point is I'm not aware of what you asked for being offered on most common operating systems but I'm not authoritative on the topic.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.