Skip to content

Instantly share code, notes, and snippets.

View tizee's full-sized avatar
🙏
Work and persevere

Jeff Chiang tizee

🙏
Work and persevere
  • Earth, Solar system
View GitHub Profile
@tizee
tizee / osexpp.c
Created June 18, 2018 09:41
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;
}
nor $1, $0, $0; #$1 = ~ ($0 | $0) = FFFF_FFFF
sltu $2, $0, $1; #$2 = $0 < $1 ? 1 : 0 = 0000_0001
add $3, $2, $2; #$3 = $2 + $2 = 0000_0002
add $4, $3, $2; #$4 = $3 + $2 = 0000_0003
add $5, $4, $3; #$5 = $4 + $3 = 0000_0005
add $6, $5, $3; #$6 = $5 + $3 = 0000_0007
sllv $7, $6, $2; #$7 = $6 << $2 = 0000_000E
add $9, $5, $6; #$9 = $5 + $6 = 0000_000C
sllv $8, $6, $9; #$8 = $6 << $9 = 0000_7000
xor $9, $1, $8; #$9 = $1 ^ $8 = FFFF_8FFF