thendal
Programmer
- Aug 23, 2000
- 284
I am asked to build a \pro_ler" for the Linux kernel scheduler. & to add code to the existing Linux kernel's schedule() function so that upon every 1000th call, a sequence of information is
printed to the system log _le (/var/log/messages). This information should include:
_ the PID of the process currently running on the CPU being scheduled for,
_ the total number of tasks in the active runqueue,
_ the total number of tasks in the expired runqueue,
_ the total number of tasks waiting for I/O,
_ for each possible priority:
{ if there are no processes with this priority, do nothing
{ if there are processes with this priority, then print out:
_ the priority value,
_ for each active process of this priority:
_ the process ID,
_ the executable name,
_ the time slice left,
_ the static priority,
_ the dynamic priority,
_ the interactivity count.
_ the same for each expired process of this priority.
Example Output
After booting your kernel, sections similar to this should show up in /var/log/messages:
Sep 13 15:14:42 bluehen kernel: ~~~~~~~~~ BEGIN SCHEDULER PROFILE ~~~~~~~~~
Sep 13 15:14:42 bluehen kernel: The pid running right now is 4633
Sep 13 15:14:42 bluehen kernel: The number of active tasks is 3
Sep 13 15:14:42 bluehen kernel: The number of expired tasks is 6
Sep 13 15:14:42 bluehen kernel: The number of tasks waiting on I/O is 0
Sep 13 15:14:42 bluehen kernel: =====PRIORITY: 115====
Sep 13 15:14:42 bluehen kernel: 4633(netscape-bin), TSL=106, PRS=120, PRD=115, I
C=101
Sep 13 15:14:42 bluehen kernel: ------
Sep 13 15:14:42 bluehen kernel: =====PRIORITY: 125====
Sep 13 15:14:42 bluehen kernel: ------
Sep 13 15:14:42 bluehen kernel: 4573(a.out), TSL=102, PRS=120, PRD=125, IC=-101,
Sep 13 15:14:42 bluehen kernel: 4572(a.out), TSL=102, PRS=120, PRD=125, IC=-101
Sep 13 15:14:42 bluehen kernel: =====PRIORITY: 135====
Sep 13 15:14:42 bluehen kernel: ------
Sep 13 15:14:42 bluehen kernel: 4560(a.out), TSL=53, PRS=130, PRD=135, IC=-101
Sep 13 15:14:42 bluehen kernel: =====PRIORITY: 139====
Sep 13 15:14:42 bluehen kernel: 4564(a.out), TSL=9, PRS=139, PRD=139, IC=-101,
Sep 13 15:14:42 bluehen kernel: 4563(a.out), TSL=10, PRS=139, PRD=139, IC=-101
Sep 13 15:14:42 bluehen kernel: ------
Sep 13 15:14:42 bluehen kernel: 4569(a.out), TSL=29, PRS=135, PRD=139, IC=-101,
Sep 13 15:14:42 bluehen kernel: 4567(a.out), TSL=29, PRS=135, PRD=139, IC=-101,
Sep 13 15:14:42 bluehen kernel: 4566(a.out), TSL=10, PRS=139, PRD=139, IC=-101
Appreciate any input.
printed to the system log _le (/var/log/messages). This information should include:
_ the PID of the process currently running on the CPU being scheduled for,
_ the total number of tasks in the active runqueue,
_ the total number of tasks in the expired runqueue,
_ the total number of tasks waiting for I/O,
_ for each possible priority:
{ if there are no processes with this priority, do nothing
{ if there are processes with this priority, then print out:
_ the priority value,
_ for each active process of this priority:
_ the process ID,
_ the executable name,
_ the time slice left,
_ the static priority,
_ the dynamic priority,
_ the interactivity count.
_ the same for each expired process of this priority.
Example Output
After booting your kernel, sections similar to this should show up in /var/log/messages:
Sep 13 15:14:42 bluehen kernel: ~~~~~~~~~ BEGIN SCHEDULER PROFILE ~~~~~~~~~
Sep 13 15:14:42 bluehen kernel: The pid running right now is 4633
Sep 13 15:14:42 bluehen kernel: The number of active tasks is 3
Sep 13 15:14:42 bluehen kernel: The number of expired tasks is 6
Sep 13 15:14:42 bluehen kernel: The number of tasks waiting on I/O is 0
Sep 13 15:14:42 bluehen kernel: =====PRIORITY: 115====
Sep 13 15:14:42 bluehen kernel: 4633(netscape-bin), TSL=106, PRS=120, PRD=115, I
C=101
Sep 13 15:14:42 bluehen kernel: ------
Sep 13 15:14:42 bluehen kernel: =====PRIORITY: 125====
Sep 13 15:14:42 bluehen kernel: ------
Sep 13 15:14:42 bluehen kernel: 4573(a.out), TSL=102, PRS=120, PRD=125, IC=-101,
Sep 13 15:14:42 bluehen kernel: 4572(a.out), TSL=102, PRS=120, PRD=125, IC=-101
Sep 13 15:14:42 bluehen kernel: =====PRIORITY: 135====
Sep 13 15:14:42 bluehen kernel: ------
Sep 13 15:14:42 bluehen kernel: 4560(a.out), TSL=53, PRS=130, PRD=135, IC=-101
Sep 13 15:14:42 bluehen kernel: =====PRIORITY: 139====
Sep 13 15:14:42 bluehen kernel: 4564(a.out), TSL=9, PRS=139, PRD=139, IC=-101,
Sep 13 15:14:42 bluehen kernel: 4563(a.out), TSL=10, PRS=139, PRD=139, IC=-101
Sep 13 15:14:42 bluehen kernel: ------
Sep 13 15:14:42 bluehen kernel: 4569(a.out), TSL=29, PRS=135, PRD=139, IC=-101,
Sep 13 15:14:42 bluehen kernel: 4567(a.out), TSL=29, PRS=135, PRD=139, IC=-101,
Sep 13 15:14:42 bluehen kernel: 4566(a.out), TSL=10, PRS=139, PRD=139, IC=-101
Appreciate any input.