Skip to content

Instantly share code, notes, and snippets.

@tizee
Created June 18, 2018 09:41
Show Gist options
  • Save tizee/186d455c6167c67f847aa28ed14ed5fd to your computer and use it in GitHub Desktop.
Save tizee/186d455c6167c67f847aa28ed14ed5fd to your computer and use it in GitHub Desktop.
os_exp1
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