开发者

Linux Kernel Process Management

开发者 https://www.devze.com 2023-01-22 23:04 出处:网络
First, i admit all the things i will ask are about our homework but i assure you i am not asking without struggling at least two hours.

First, i admit all the things i will ask are about our homework but i assure you i am not asking without struggling at least two hours.

Description: We are supposed to add a field called max_cpu_percent to task_struct data type and manipulate process scheduling algorithm so that processes can not use an higher percentage of the cpu.

for example if i set max_cpu_percent field as 20 for the process firefox, firefox will not be able to use more than 20% of the cpu.

We wrote a system call to set max_cpu_p开发者_如何学Goercent field. Now we need to see if the system call works or not but we could not get the value of the max_cpu_percent field from a user-spaced program. Can we do this? and how?

We tried proc/pid/ etc can we get the value using this util?

By the way, We may add additional questions here if we could not get rid of something else

Thanks All

Solution:

The reason was we did not modify the code block writing the output to the proc queries. There are some methods in array.c file (fs/proc/array.c) we modified the function so that also print the newly added fields value. kernel is now compiling we'll see the result after about an hour =)

It Worked...


(If you simply extended getrlimit/setrlimit, then you'd be done by now…)

There's already a mechanism where similar parts of task_struct are exposed: /proc/$PID/stat (and /proc/$PID/$TID/stat). Look for functions proc_tgid_stat and proc_tid_stat. You can add new fields to the ends of these files.

0

精彩评论

暂无评论...
验证码 换一张
取 消