5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2002 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
23 #include "silcincludes.h"
24 #include "silcschedule_i.h"
26 /* Calls normal select() system call. */
28 int silc_select(SilcScheduleFd fds, uint32 fds_count, struct timeval *timeout)
31 int ret, i, max_fd = 0;
36 for (i = 0; i < fds_count; i++) {
40 if (fds[i].fd > max_fd)
43 if (fds[i].events & SILC_TASK_READ)
44 FD_SET(fds[i].fd, &in);
45 if (fds[i].events & SILC_TASK_WRITE)
46 FD_SET(fds[i].fd, &out);
51 /* ret = select(max_fd + 1, &in, &out, NULL, timeout); */
55 for (i = 0; i < fds_count; i++) {
59 if (FD_ISSET(fds[i].fd, &in))
60 fds[i].revents |= SILC_TASK_READ;
61 if (FD_ISSET(fds[i].fd, &out))
62 fds[i].revents |= SILC_TASK_WRITE;
70 /* XXX Do this like it's done in win32/ */
72 /* Internal wakeup context. */
77 SILC_TASK_CALLBACK(silc_schedule_wakeup_cb)
82 #endif /* SILC_THREADS */
84 /* Initializes the wakeup of the scheduler. In multi-threaded environment
85 the scheduler needs to be wakenup when tasks are added or removed from
86 the task queues. This will initialize the wakeup for the scheduler.
87 Any tasks that needs to be registered must be registered to the `queue'.
88 It is quaranteed that the scheduler will automatically free any
89 registered tasks in this queue. This is system specific routine. */
91 void *silc_schedule_wakeup_init(SilcSchedule schedule)
100 /* Uninitializes the system specific wakeup. */
102 void silc_schedule_wakeup_uninit(void *context)
109 /* Wakes up the scheduler */
111 void silc_schedule_wakeup_internal(void *context)