Created
June 18, 2018 09:41
-
-
Save tizee/186d455c6167c67f847aa28ed14ed5fd to your computer and use it in GitHub Desktop.
os_exp1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SYSCALL_DEFINE3(setnice,pid_t,pid,int,flag,int,nicevalue) | |
{ | |
int errono = 0; | |
struct pid * temp_pid=find_get_pid(pid); | |
struct task_struct *p=pid_task(temp_pid,PIDTYPE_PID); | |
if(p->pid != pid) | |
{ | |
errono=-EFAULT; | |
return errono; | |
} | |
switch(flag) | |
{ | |
case(0): // Read nice value | |
{ | |
printk("the process's nice is : %d \n",task_nice(p)); | |
break; | |
} | |
case(1): // Set nice value | |
{ | |
set_user_nice(p,nicevalue); | |
printk("change nice to: %d \n",task_nice(p)); | |
break; | |
} | |
default: // wrong flag value | |
{ | |
errono=-EFAULT; | |
return errono; | |
} | |
} | |
return errono; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment