How to place a process to the runqueue?
Hello everyone! I would just want to ask how can I place a user process to a runqueue, so that when a kernel process invoked schedule(), it can be executed provided that it has a higher priority? what functions should I use?
Thanks! |
You would use the exec() system call. From there, it is up to the kernel to schedule its execution. You can influence the priority of the process using renice. After that, I don't think you can affect how the kernel manages the process.
--- rod. |
When I execute exec(), will it be executed right away? Is there other system call to make it somewhat suspended from execution, but in an interruptible state? I have tried to use sched_yield() but it is not yielding. :(
|
Okay, you've pointed me to a whole host of system calls that I didn't know about. sleep() can be interrupted by signals. Is that the level of suspension you want?
I think you are probably already more acquainted with the subject than I am. What are you attemping to accomplish with these low-level tinkerings? --- rod. |
Quote:
|
So you have two (or more) processes which you want to run in mutual exclusivity? If yes, isn't this the exact purpose of semaphores? I'm not sure you can do anything that guarantees that one process deferring to another will immediately cause a context switch. That is the domain of the scheduler.
Where you say: Quote:
--- rod. |
Yes you are correct. I used the semaphore in the user space. But I don't know where to release it since the other task that should release it is in kernel space. Now I have realized, I must make the first task to enter the kernel space and wait for the semaphore there rather than the user space so that the other task can release it in the same kernel space. Now if these two task are in kernel space, is it guaranteed that when the first task calls the schedule() it will context switch? and to be able to go back to the first task, all I have to do is call schedule() again on the other task?
Thanks! :) |
Okay, I will bow out here, because I have no expertise in kernel level programming. You are trying to do something that is somewhat unorthodox, to be sure. Passing information from kernel space to userspace is outside that sphere of most programmer's knowledge.
Two things that I would suggest to you: Re-post your questions on a forum or newsgroup dedicated to kernel programming. Look at the fuse (filesystem in userspace) package. It's primary purpose is to export kernel level 'stuff' to userspace, and it seems likely to provide examples of how to do what you are trying to do. Good luck with your project. --- rod. |
Ok thanks! :) I am also not expert in this that is why I have this problem for 2 weeks already :(
|
All times are GMT -5. The time now is 03:53 AM. |