summaryrefslogtreecommitdiff
path: root/trans
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2012-09-03 15:47:25 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-11-24 18:46:46 +0100
commit7648503cd894549874ff13f7ed94a4708cf50f0d (patch)
treed31187eabbacf81debf2bc4473b014c116ecbf34 /trans
parentb2d57eb33ddd8f24929f372bfb08bac3a29ac6ea (diff)
Remove condition implications
There is no equivalent for these functions in libpthread. Instead of adding them as non standard extensions, rework their use. * console-client/kbd-repeat.c (kbd_repeat_key): Wake threads waiting on select_alert. (kbd_setrepeater): Remove call to condition_implies. console-client/pc-mouse.c (repeat_event): Wake threads waiting on select_alert. (setrepeater): Remove call to condition_implies. * libpipe/pipe.c (pipe_create): Initialize the `pending_selects' member. (pipe_add_select_cond): New function. (pipe_remove_select_cond): Likewise. (pipe_select_cond_broadcast): Likewise. (_pipe_no_readers): Wake threads waiting on a pending select. (_pipe_no_writers): Likewise. (pipe_send): Likewise. (pipe_recv): Likewise. (pipe_pair_select): Replace condition implications by installing a pending select on the pair of pipes. * libpipe/pipe.h (struct pipe_select_cond): New type. (struct pipe): New member `pending_selects'. * pfinet/tunnel.c (tunnel_xmit): Wake threads waiting on tdev->select_alert. (setup_tunnel_device): Remove call to condition_implies. * term/devio.c (device_write_reply_inband): Wake threads waiting on select_alert. * term/hurdio.c (hurdio_writer_loop): Likewise. * term/main.c (main): Remove calls to condition_implies. * term/ptyio.c (ptyio_init): Remove calls to condition_implies, initialize pty_select_alert. (wake_reader): Wake threads waiting on pty_select_wakeup. * term/term.h (pty_select_alert): New variable. (clear_queue): Wake threads waiting on select_alert and, if acting on the input queue, pty_select_alert, unless it's NULL. (dequeue_quote): Likewise. (enqueue_internal): Likewise. (queue_erase): Likewise. * trans/streamio.c (clear_buffer): Wake threads waiting on select_alert. (buffer_read): Likewise. (buffer_write): Likewise. (device_read_reply_inband): Likewise. (device_write_reply_inband): Likewise. (main): Remove calls to condition_implies.
Diffstat (limited to 'trans')
-rw-r--r--trans/streamio.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/trans/streamio.c b/trans/streamio.c
index c563c03c..9ced28b3 100644
--- a/trans/streamio.c
+++ b/trans/streamio.c
@@ -108,6 +108,7 @@ clear_buffer (struct buffer *b)
return;
b->head = b->tail = b->buf;
condition_broadcast (b->wait);
+ condition_broadcast (&select_alert);
}
/* Read up to LEN bytes from B to DATA, returning the amount actually read. */
@@ -132,6 +133,7 @@ buffer_read (struct buffer *b, void *data, size_t len)
}
condition_broadcast (b->wait);
+ condition_broadcast (&select_alert);
return len;
}
@@ -148,6 +150,7 @@ buffer_write (struct buffer *b, void *data, size_t len)
b->tail += len;
condition_broadcast (b->wait);
+ condition_broadcast (&select_alert);
return len;
}
@@ -300,15 +303,9 @@ main (int argc, char *argv[])
condition_init (&select_alert);
if (trivfs_allow_open & O_READ)
- {
- input_buffer = create_buffer (256);
- condition_implies (input_buffer->wait, &select_alert);
- }
+ input_buffer = create_buffer (256);
if (trivfs_allow_open & O_WRITE)
- {
- output_buffer = create_buffer (256);
- condition_implies (output_buffer->wait, &select_alert);
- }
+ output_buffer = create_buffer (256);
/* Launch */
ports_manage_port_operations_multithread (streamdev_bucket, demuxer,
@@ -999,6 +996,7 @@ device_read_reply_inband (mach_port_t reply, error_t errorcode,
data += nwritten;
datalen -= nwritten;
condition_broadcast (input_buffer->wait);
+ condition_broadcast (&select_alert);
}
}
else
@@ -1102,6 +1100,7 @@ device_write_reply_inband (mach_port_t reply, error_t returncode, int amount)
{
npending_output = 0;
condition_broadcast (output_buffer->wait);
+ condition_broadcast (&select_alert);
}
else
{