[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hurd-bug
Subject:    schedule_timeout()
From:       "kurian  kattukaren" <kjk_bugs () rediffmail ! com>
Date:       2001-08-30 19:45:37
[Download RAW message or body]


On Thu, 30 Aug 2001 Marcus Brinkmann wrote :
>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)
>>  {      
           thread_t current;
           struct time_list timer;
           long int expire;
           
           current = mach_thread_self();
>>         expire = timeout + jiffies;
>> 
>>         init_timer(&timer);
>>         timer.expires = expire;
>>         timer.data = (unsigned long) current;
>>         timer.function = process_timeout;
>> 
>>         add_timer(&timer);
>>         thread_suspend(current);
            del_timer(&timer);
            
         return timeout;
 }

void process_timeout(unsingned long data)
 {
  thread_t thread = (thread_t)data;
  if (data != schedule_timeout)
     thread_resume(schedule_timeout);
  
 return ;
 }

>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.

When two threads have the same process_timeout function
then there is a possible that one of the threads might
be resumed earlier than the timeout.


 





[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic