LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-24-2007, 03:17 AM   #1
archieval
Member
 
Registered: Apr 2007
Location: Philippines
Distribution: Kubuntu, Ubuntu, CentOS
Posts: 289

Rep: Reputation: 41
Exclamation 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!
 
Old 04-24-2007, 01:29 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 04-24-2007, 08:18 PM   #3
archieval
Member
 
Registered: Apr 2007
Location: Philippines
Distribution: Kubuntu, Ubuntu, CentOS
Posts: 289

Original Poster
Rep: Reputation: 41
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.
 
Old 04-24-2007, 11:45 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 04-25-2007, 12:39 AM   #5
archieval
Member
 
Registered: Apr 2007
Location: Philippines
Distribution: Kubuntu, Ubuntu, CentOS
Posts: 289

Original Poster
Rep: Reputation: 41
Quote:
Originally Posted by theNbomr
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?
Somewhat yes, but I don't want it to be time dependent. I want it to be just waiting. I have tried using semaphores but of course when the scheduler in the kernel space is invoked, it will execute the waiting task, but it is waiting for a semaphore. I don't know where to release the semaphore. I am using the SCHED_FIFO policy on the two tasks so that only one will be active unless one yields the cpu. But I have failed on doing this. If only sched_yield will work properly.
 
Old 04-25-2007, 09:27 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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:
I have tried using semaphores but of course when the scheduler in the kernel space is invoked, it will execute the waiting task, but it is waiting for a semaphore
this doesn't sound quite right. As I understand it, a process blocked on a semaphore will not execute, which is how semaphores become a big efficiency gain vs. busy-waiting on a flag. Have I misunderstood you?

--- rod.
 
Old 04-25-2007, 10:05 PM   #7
archieval
Member
 
Registered: Apr 2007
Location: Philippines
Distribution: Kubuntu, Ubuntu, CentOS
Posts: 289

Original Poster
Rep: Reputation: 41
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!
 
Old 04-26-2007, 10:11 AM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 04-26-2007, 09:35 PM   #9
archieval
Member
 
Registered: Apr 2007
Location: Philippines
Distribution: Kubuntu, Ubuntu, CentOS
Posts: 289

Original Poster
Rep: Reputation: 41
Ok thanks! I am also not expert in this that is why I have this problem for 2 weeks already
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how a father process know which child process send the signal SIGCHLD icoming Programming 10 07-20-2010 07:26 AM
Need to install process at end of boot process ch485de Linux - Newbie 5 12-07-2006 05:47 PM
child process usses same amount of ram as parent process socialjazz Programming 7 10-19-2006 05:48 PM
Process Table-Process Control Block sarahmencer Linux - General 1 01-09-2006 09:14 PM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 01:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration