[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
schedule_timeout()
From: |
kurian kattukaren |
Subject: |
schedule_timeout() |
Date: |
30 Aug 2001 19:45:37 -0000 |
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 Thread] |
Current Thread |
[Next in Thread] |
- schedule_timeout(),
kurian kattukaren <=