[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: [LI] scheduling in Linux



On Sat, Jan 15, 2000 at 01:19:38PM +0530, Pushkala Iyer wrote:
> 
> Hi,
> 
>    I have a multithreaded application. In one of the threads, I'm required
> to do something at particular intervals of a 45 kHz clock. I simulate the
> 45kHz clock from the system clock (the gettimeofday system call gives the
> system time in 1MHz resolution). My problem is that the thread gets
> swapped out, so sometimes the time difference between 2 gettimeofday calls
> is greatly different. I have these doubts. 

I'm not sure how you're using gettimeofday. Are you in a tight loop,
reading gettimeofday ? Perhaps, a better idea is to use alarm(2)
or setitimer(2).

> 
> 
> If I increase the priority of the concerned thread, using the
> sched_setscheduler system call, will it require me to change the
> scheduling policies of the other threads also? - in other words, is it
> possible for me to have just one thread in the application to have a real
> time scheduling policy, and others at default scheduling policy? Will my
> other threads get scheduled?
> 

If you increase the priority of one thread to be real time, that
thread will have a priority over all other threads in the system.

In other words, if thread A (with real time priority) is ready to
run, then all other threads will have to wait till A completes
its time slice and goes into a non-runnable state.

> I've also seen some programs using sleep(0). What does sleep(0) mean? Does
> it just relinquish processor time? Does the nanosleep system call also
> relinquish processor time?  

sleep(0) forces the delivery of a SIGALRM immediately. It could (for that
matter, any system call) result in preemption. Everytime a process
returns from the system call, a check will be done to see if the time
slice for the thread/process has expired. 

	-Arun
--------------------------------------------------------------------
The Linux India Mailing List Archives are now available.  Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.