How to pass a value into a system call function in XV6?

后端 未结 1 1061
旧时难觅i
旧时难觅i 2021-02-20 12:39

I am attempting to create a simple priority based scheduler in XV6. To do this, I also have to create a system call that will allow a process to set its priority. I have done

1条回答
  •  被撕碎了的回忆
    2021-02-20 12:42

    Passing arguments from user-level functions to kernel-level functions cannot be done in XV6. XV6 has its own built-in functions for passing arguments into a kernel function. For instance, to pass in an integer, the argint() function is called. In the implementation that I used for the set-priority function, that would look something like:

    argint(0, &pid);
    

    ... to get the first argument which is the Process ID, and:

    argint(1, &pty);
    

    ... to get the second argument which is the desired priority. The function call from the user process looks like this:

    setpty(getpid(), priority);
    

    0 讨论(0)
提交回复
热议问题