Re: Access to kernel routine (find_task_by_pid)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Vincenzo Mallozzi wrote

1. sched_getscheduler(): queries the scheduling policy currently applied to 2. sched_getparam(): retrieves the scheduling parameters for the process 3. sched_yield(): allows a process to relinquish the CPU voluntarily without 4. sched_rr_get_interval(): should get the round robin time quantum for the

I already try to implement a cpuburner with the three first functions. This old approache reduced the load of other program if the burner has RT priority but the communication are also reduce and the idea was to reduce only the cpu.
I don't know how they can be useful in this new approache.

I also suggest you this strategies.
Create a kernel module that have one function set and one function get fro each of the field you want to modify. Then you create a function that initialize a timer and one by which you can modify it. Finally, a function that make the whole works. First, initializes the timer, then call the modifiers of process descriptor fields of monitoring processes. You can also provide an interface by means the ioctl/read mechanism in order to call all these functions by user space. For this, I suggest you to read "Linux Device Driver".


I don't understand your strategy.
In fact, the current algo looks like this :
pid = get_pid_of_the_process_to_control ()
while (1) {
if (cpu_usage_of_process (pid) * 100 > total_time_since_the_start (pid) * percent) {
   kill (SIGSTOP, pid);
   usleep (1); usleep (1); //depend on HZ const
   kill (SIGCONT, pid);
 }
}
I don't know if it is the best solution for controlling the process but it works (I have just to use the utime and starttime field of the /proc/<pid>/stat file). Do you think that it is possible to influence the scheduling of a process with the counter and priority fields in the same way with a module ? Or is there better way to make a process sleep in the kernel space (because I should force the process to suspend its process each ms to have a fine granularity) ?

For sake of completeness, I lists the chapter you have to study to better understand in which way you can implement your project: - Chapter "Building and Running Modules" from "Linux Device Drivers" (to learn building modules)

- Chapter "Process Scheduling" from "Understanding Linux Kernel" (Only the sections "Scheduling Policy" and "The Scheduling Algorithm" - to better understand the mechanism of get/relinquish CPU)

- Chapter "Timing Measurements" from "Understanding Linux Kernel" (Only parts of it regarding static and dynamic timers). In order to give you the possibilities to skip this chapter, I can provide you a brief description of the methods you've to use without the need for you to study an entire chapter.

- [optional] Chapter "Char Drivers" and "Advanced Char Driver Operations" to better understand the read/write/ioctl mechanism. This is necessary if you want to communicate between user space and kernel module.


Really good. I have "Understanding Linux Kernel" and "Linux Device Drivers" in available online. I will read these chapters and take the time to implement a basic module. Then I will see if there is other way to improve this.

Thanks

Sincerly,

--
Canon


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux