bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: thread_suspend()


From: Marcus Brinkmann
Subject: Re: Re: thread_suspend()
Date: Thu, 30 Aug 2001 18:09:10 +0200
User-agent: Mutt/1.3.20i

On Thu, Aug 30, 2001 at 02:55:54PM -0000, kurian  kattukaren wrote:
> 
> thread_t current = mach_current_thread();
> int long schedule_timeout(long int timeout)
>  {
>         expire = timeout + jiffies;
> 
>         init_timer(&timer);
>         timer.expires = expire;
>         timer.data = (unsigned long) current;
>         timer.function = process_timeout;
> 
>         add_timer(&timer);
>   /*      schedule(); */
>         thread_suspend(current);
>         thread_resume(current);

If you suspend a thread, it can't resume itself, some other thread must
do it.  I think you should resume the thread in process_timeout.
That's why you set timer.data to the current thread, so it knows which
thread to resume.

Also, your handling of the current thread is incorrect.  "current" already
is defined as a macro for another purpose, and shouldn't be a global variable
anyway.  The thread port is returned by mach_thread_self(), there is no such
thing as mach_current_thread().

So if you move the thread_resume to process_timeout, you might achieve what
you wanted to achieve.  Note that I don't know if this is the correct
behaviour for schedule_timeout, I am just looking at your code "locally" ;)
(I am worrying a bit because you set the thread in suspend state which is
not interruptible.  Maybe this should use interruptible_sleep_on and
wake_up instead, but I don't know if this will do the right thing either).

Thanks,
Marcus

 
-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]