|
AquilaOS documentation
How it works, and its code
|
#include <ds/list.h>Go to the source code of this file.
Data Structures | |
| struct | waitq |
Functions | |
| int | waitq_sleep (struct waitq *waitq) |
| Puts the current thread to sleep on a wait queue until it is woken up. | |
| void | waitq_sleep_unint (struct waitq *waitq) |
| Puts the current thread to sleep on a wait queue until it is woken up, whatever signals come meanwhile. | |
| void | waitq_wakeup (struct waitq *waitq) |
| Wakes up every thread sleeping on a wait queue, and every thread polling it. | |
| void | waitq_wakeup_nopoll (struct waitq *waitq) |
| Wakes up every thread sleeping on a wait queue, but not the threads polling it. | |
| void | thread_wakeup (struct thread *thread) |
| Wakes up one thread, if it is sleeping on a wait queue. | |
| int | poll_register (struct waitq *waitq) |
| Registers a wait queue that the current thread, in select() or poll(), waits for: a wakeup of that queue also wakes the thread. | |
| void | poll_unregister (struct thread *thread) |
| Removes every registration of a thread, when it stops waiting (it was woken up, or it is going away). | |
| int poll_register | ( | struct waitq * | queue | ) |
Registers a wait queue that the current thread, in select() or poll(), waits for: a wakeup of that queue also wakes the thread.
Registering the same queue twice does nothing.
| queue | the wait queue, or NULL to be woken by any wakeup |
Definition at line 112 of file waitq.c.
References curthread, kmalloc(), poll_reg::next, poll_chain(), poll_register(), poll_regs, thread::poll_regs, poll_reg::queue, poll_reg::thread, and poll_reg::thread_next.
Referenced by fd_watch(), and poll_register().
| void poll_unregister | ( | struct thread * | thread | ) |
Removes every registration of a thread, when it stops waiting (it was woken up, or it is going away).
| thread | the thread whose registrations go |
Definition at line 144 of file waitq.c.
References kfree(), poll_reg::next, poll_chain(), poll_regs, thread::poll_regs, poll_unregister(), poll_reg::queue, and poll_reg::thread_next.
Referenced by poll_unregister(), sys_poll(), sys_select(), and thread_kill().
| void thread_wakeup | ( | struct thread * | thread | ) |
Wakes up one thread, if it is sleeping on a wait queue.
The other threads on that queue keep sleeping.
| thread | the thread to wake up |
Definition at line 216 of file waitq.c.
References NULL, thread::run_link, sched_thread_wake(), thread_wakeup(), and thread::waitq.
Referenced by net_callout_set(), rx_queue(), sched_timer_tick(), signal_to(), and thread_wakeup().
| int waitq_sleep | ( | struct waitq * | waitq | ) |
Puts the current thread to sleep on a wait queue until it is woken up.
A signal that the process doesn't block also ends the sleep (signal_to() wakes the thread). The system call should then return, so that the signal can be delivered. If a signal is already pending, the thread doesn't sleep at all.
A wakeup only means that something changed, so callers sleep in a loop and look again at what they wait for each time.
| waitq | the wait queue to sleep on |
Definition at line 50 of file waitq.c.
References curthread, ERESTARTSYS, ISLEEP, signal_interrupts(), sleep_on(), and waitq_sleep().
Referenced by pipefs_fifo_open(), posix_file_write(), pty_master_write(), pty_slave_write(), sched_wait(), socket_unix_accept(), socket_unix_connect(), socket_unix_recv(), socket_unix_send(), sys_sigsuspend(), sys_thread_join(), sys_waitpid(), tty_wait_start(), vfs_file_flock(), vt_kd_ioctl(), and waitq_sleep().
| void waitq_sleep_unint | ( | struct waitq * | waitq | ) |
Puts the current thread to sleep on a wait queue until it is woken up, whatever signals come meanwhile.
This is for waits that can't be abandoned halfway, such as a disk transfer or a page being read in.
| waitq | the wait queue to sleep on |
Definition at line 67 of file waitq.c.
References sleep_on(), USLEEP, and waitq_sleep_unint().
Referenced by channel_acquire(), dma_transfer(), proc_threads_exec(), signal_stop(), and waitq_sleep_unint().
| void waitq_wakeup | ( | struct waitq * | waitq | ) |
Wakes up every thread sleeping on a wait queue, and every thread polling it.
The threads become ready to run.
| waitq | the wait queue (NULL does nothing) |
Definition at line 178 of file waitq.c.
References poll_regs, poll_wake(), waitq_wakeup(), and waitq_wakeup_nopoll().
Referenced by inet_sock_deliver(), inet_sock_error(), lock_unlock(), pipefs_close(), pipefs_fifo_open(), posix_file_read(), posix_file_write(), proc_zombie_notify(), ps2mouse_handler(), ptm_read(), pts_read(), pty_free(), sched_thread_killed(), signal_notify_parent(), signal_to(), socket_inet_shut(), socket_unix_accept(), socket_unix_connect(), socket_unix_recv(), socket_unix_send(), socket_unix_shutdown(), sys_thread_exit(), tcp_wakeup(), tty_free(), tty_ioctl(), tty_master_write(), uart_receive_handler(), uart_transmit_handler(), unix_conn_wakeup(), vfs_file_flock(), vt_input_to(), vt_switch_now(), and waitq_wakeup().
| void waitq_wakeup_nopoll | ( | struct waitq * | waitq | ) |
Wakes up every thread sleeping on a wait queue, but not the threads polling it.
This is for queues that no file descriptor waits through, such as a disk request's, and for the pollers' own queues.
| waitq | the wait queue (NULL does nothing) |
Definition at line 196 of file waitq.c.
References list_entry, NULL, thread::run_link, sched_thread_wake(), waitq::threads, thread::waitq, and waitq_wakeup_nopoll().
Referenced by channel_release(), dma_irq(), poll_wake(), waitq_wakeup(), and waitq_wakeup_nopoll().