Find the answer to your Linux question:
Results 1 to 3 of 3
Hello All, Is it possible to detect when a particular process is interrupted? For example, let us say that we have three process running A, B, C. The scheduler is ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2008
    Posts
    2

    Linux CPU Scheduler


    Hello All,

    Is it possible to detect when a particular process is interrupted? For example, let us say that we have three process running A, B, C. The scheduler is constantly switching tasks between A, B, and C. What I want to be able to do is detect when the CPU interrupts process B (here I want to clear an arbitrary flag) to run another process. Once the other process has completed, or the time quanta has expired, process B will resume. Once process B resumes, I want to set my arbritary flag that I had cleared earlier. Is this possible? Would I have to create my own kernel module, or would I have to modify the CPU scheduler (hopefully no)?

    I am looking for any insight or help that could get me started. Thanks for your help and I look forward to your feedback.

    Here is some info on my system:
    2.6.23-gentoo-r9
    i686 Intel(R) Pentium(R) 4 CPU 3.00GHz GenuineIntel GNU/Linux

    Regards,
    JQ

  2. #2
    Just Joined!
    Join Date
    Jul 2008
    Posts
    2
    What about detecting when a process's cpu utilization goes above 0.0%? As you know, when a process is executing it is using the CPU. When the cpu is not executing the process, the process is idle and its cpu utilization should be zero (i.e. the process was preempted and the cpu is executing some other process). I know you can get good information on a particular process. For example, if you do something like:

    top -b -n 1 | grep my_process

    you would get the stats for my_process, i.e. PID, %CPU, %MEM, etc.

    I wonder if there is a way to monitor the process I want, and when its CPU utilization rises above 0.0 %, I can set my flag. The problem is that I don't want to use a method that involves polling. Ideally I would like to use something that is interrupt driven. Is it possible to create such an interrupt (i.e. interrupt when process cpu > 0.0 and interrupt when process cpu == 0.0)? I'm hoping something like this is feasible. In either case, I look forward to any feedback you all may have. Thanks in advance.

    Regards,
    JQ

  3. #3
    Just Joined!
    Join Date
    Jun 2008
    Posts
    1
    That's a great question, but you chose the wrong place to post it as this is definitely a kernel and/or programming question. I've got a lot of ideas, none of which hit the nail on the head, but I think I can point you in the right direction.

    First of all this sounds like the job of a profiling program or routing, and both the FOSS and commercial world are full of these, with even specific profiling routines found in the Linux kernel (in the 2nd menu, I believe, under BSD and POSIX process accounting, as well as some internal kernel profiling stuff near the end in the kernel hacking menu). As I was Googling for "linux profiling", I came across this gem:

    http://www.cs.uoregon.edu/research/p...rs/linux99.pdf

    I'm not sure whether the "99" here is the year since the paper doesn't have a copyright or any other date, so the info may be old, but presents a great overview from this amateur's standpoint.

    Also by Googling "linux profiling" you'll find links to the big debuggers/profilers used by even commercial software makers: Valgrind, OProfile, etc.

    Good Luck!

    Mike


    Quote Originally Posted by jqweezy View Post
    Hello All,

    Is it possible to detect when a particular process is interrupted? For example, let us say that we have three process running A, B, C. The scheduler is constantly switching tasks between A, B, and C. What I want to be able to do is detect when the CPU interrupts process B (here I want to clear an arbitrary flag) to run another process. Once the other process has completed, or the time quanta has expired, process B will resume. Once process B resumes, I want to set my arbritary flag that I had cleared earlier. Is this possible? Would I have to create my own kernel module, or would I have to modify the CPU scheduler (hopefully no)?

    I am looking for any insight or help that could get me started. Thanks for your help and I look forward to your feedback.

    Here is some info on my system:
    2.6.23-gentoo-r9
    i686 Intel(R) Pentium(R) 4 CPU 3.00GHz GenuineIntel GNU/Linux

    Regards,
    JQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •