summaryrefslogtreecommitdiff
path: root/fibers (follow)
Commit message (Expand)AuthorAgeFilesLines
* Better findability for epoll extension.•••* fibers/config.scm.in: New file. * Makefile.am: Wire up new file. * env.in: Define FIBERS_BUILD_DIR. * fibers/epoll.scm: Use (fibers config) to get dir for epoll extension. Andy Wingo2017-01-192-1/+33
* Randomized round-robin work sharing/stealing•••* fibers.scm (start-auxiliary-threads, stop-auxiliary-threads): Adapt to scheduler-remote-peers change. (spawn-fiber): Adapt to use choose-parallel-scheduler. * fibers/internal.scm (<scheduler>): Add choose-parallel-scheduler field. (shuffle, make-selector): New helpers. (make-scheduler): Adapt to initialize choose-parallel-scheduler field. (choose-parallel-scheduler): New public function. (run-scheduler): Use fiber-stealer. Andy Wingo2017-01-181-28/+54
* create-fiber always captures dynamic state•••* fibers/internal.scm (create-fiber): Remove dynamic-state argument; always capture the current dynamic state. * fibers/timers.scm (timer-operation): * fibers.scm (spawn-fiber): Adapt. Andy Wingo2017-01-082-11/+11
* Peer schedulers share a prompt tag•••* fibers/internal.scm (make-scheduler): Peer schedulers share a prompt tag. This eliminates TOCTTOU bugs in suspend-current-fiber when computing the suspension prompt tag. (run-scheduler): Inline run-fiber and just use the same prompt tag for all fibers. Andy Wingo2017-01-081-15/+17
* Fix race between with-interrupts and thread start•••* fibers/interrupts.scm (with-interrupts/thread-cputime): Fix race. Andy Wingo2017-01-081-4/+10
* Fix clock-nanosleep wrapper•••* fibers/posix-clocks.scm (clock-nanosleep): clock_nanosleep returns the error value directly; it doesn't set errno. Fix. Andy Wingo2017-01-081-9/+7
* Add support for operations from foreign threads•••* tests/foreign.scm: New file. * Makefile.am: Add new file. * fibers/operations.scm (perform-operation): Support blocking operations from foreign threads (without a scheduler). * fibers/timers.scm (timer-sched, *timer-sched*, timer-operation): Add support for timeouts that use an auxiliary thread instead of relying on the current scheduler. Andy Wingo2017-01-052-2/+51
* Remove epoll dep on suspendable ports•••* epoll.c (scm_primitive_epoll_wake): New function. (scm_primitive_epoll_wait): If the epoll was woken, drain the read pipe directly. (init_fibers_epoll): Adapt prototypes. * fibers/epoll.scm (epoll-wake!): Use primitive-epoll-wake. (epoll): Let primitive-epoll-wait handle wakeup. Andy Wingo2017-01-041-17/+5
* Centralize operation wrap handling•••* fibers/operations.scm (<base-op>): Update comment. (perform-operation): Wrap resume proc before calling block function. * fibers/channels.scm (put-operation, get-operation): * fibers/timers.scm (timer-operation): Adapt to pre-wrapped resume proc. Andy Wingo2017-01-043-28/+28
* Prepare for support for blocking operations•••* fibers/operations.scm (perform-operation): Block function takes sched and resume function, not fiber. Will allow blocking operations in the future. * fibers/internal.scm (add-timer): Rename from resume-on-timer; just call a thunk after a time has passed. * fibers/timers.scm (timer-operation): Adapt to resume-on-timer and operation changes. * fibers/channels.scm (put-operation, get-operation): Adapt to operation changes. Andy Wingo2017-01-044-62/+58
* Fix ,spawn-fiber•••* fibers/repl.scm (spawn-fiber): Use spawn-fiber instead of create-fiber to get right dynamic-state. Andy Wingo2016-12-301-1/+1
* Flesh out remote peers interface•••* fibers/internal.scm (<scheduler>): Add remote-peers setter, and expose getter publically. (make-scheduler): Change remote-peers arg to "parallelism", and use setter to initialize remote peers. Andy Wingo2016-12-291-3/+14
* C-c works on threads stuck in epoll•••* epoll.c (scm_primitive_epoll_wait): Add wakefd argument, and use facilities from git guile to ensure that C-c will wake a thread sleeping in epoll. (init_fibers_epoll): Declare additional primitive-epoll-wait arg. * fibers/epoll.scm (epoll): Tell Guile about the wake fd. Andy Wingo2016-12-291-1/+3
* Fix yield-current-fiber•••* fibers/internal.scm (yield-current-fiber): Fix to allow yield-current-fiber to be run from an interrupt tick, when it's possible that no fiber is current. Andy Wingo2016-12-231-5/+8
* Enable work stealing in run-scheduler•••* fibers.scm (run-fibers): Store result in an atomic box, given that the initial fiber could migrate. * fibers/internal.scm (<scheduler>): Add remote-peers field. (<fiber>): Add set-fiber-scheduler!. (make-scheduler): Adapt to <scheduler> change. (scheduler-finished?): New helper. (scheduler-poll-timeout): Take a finished? predicate to know when to wait and when to return directly. (schedule-runnables-for-next-turn): Plumb finished? predicate through. (run-scheduler): Avoid returning until finished? is true. Refactor to add work stealing. (steal-fiber!): New helper. Andy Wingo2016-12-221-37/+53
* Get current scheduler from current fiber•••* fibers.scm (run-fibers): Refine #:keep-scheduler? default. (current-fiber-scheduler): Rename from require-current-scheduler, and use the current fiber to get at the scheduler. (spawn-fiber): Let create-fiber handle dynamic state shenanigans, as it needs to ensure that current-fiber is bound in the thunk. * fibers/internal.scm (with-scheduler): Don't parameterize current-scheduler, as that binding for a given scheduler needs to change over time, and the with-dynamic-state prevents this from happening. (schedule-fiber!): Wake schedulers not on the current kernel thread. (run-fiber): Don't parameterize current-fiber; it's lost across the with-dynamic-state. (create-fiber): Instead set current-fiber inside the with-dynamic-state. (suspend-current-fiber, yield-current-fiber): Get current scheduler from current fiber. Andy Wingo2016-12-221-27/+25
* run-scheduler pops one fiber at a time•••* fibers/internal.scm (run-scheduler): Pop one fiber at a time. Andy Wingo2016-12-221-13/+15
* Rework runqueue as pair of stacks•••* fibers/stack.scm: New file. * Makefile.am: Add new file. * fibers/internal.scm: Rework runqueue to have separate current and next stacks. We want to expose the current runqueue so that remote schedulers can steal work, but we also need to know when we flip the next runqueue to the current runqueue so that we can pull in additional wakeups from epoll and timers. Andy Wingo2016-12-222-23/+92
* Beginnings of work stealing•••* fibers/deque.scm (update!): Don't spin if value didn't change. (dequeue!): New function. * fibers/internal.scm (schedule-fibers-for-fd): Add comment about stealing and fd's. (steal-work!): New internal function. Andy Wingo2016-12-212-4/+26
* Add REPL commands to manualAndy Wingo2016-12-161-1/+1
* Factor interrupt generation to separate facility•••* fibers/interrupts.scm: New file. * fibers/internal.scm (<scheduler>): Remove Hz field and adapt users. (run-scheduler): Remove preemption; (fibers) handles this now. (yield-current-fiber): New primitive. * fibers.scm (run-fibers): Use interrupts module and wrap run-scheduler in `with-interrupts'. * Makefile.am: Add new file. Andy Wingo2016-12-162-50/+105
* Add posix-clocks.scm•••* fibers/posix-clocks.scm: New file. * Makefile.am: Add new file. Andy Wingo2016-12-161-0/+166
* Add support for preemption•••* Makefile.am: Add new test. * TODO.md: Remove stale TODO entries. * fibers.scm (run-fibers): Add #:hz parameter. * fibers.texi (Design): Mention that we support preemption. (Using Fibers): Update for preemption. * fibers/internal.scm (<scheduler>): Add hz field. (make-scheduler): Add #:hz initarg. (maybe-preemptive): New helper. (run-scheduler): Use maybe-preemptive. * tests/preemption.scm: New test. Andy Wingo2016-12-121-18/+49
* Error on attempt to suspend unsuspendable continuations•••* fibers/internal.scm (suspend-current-fiber): Error if the fiber is not suspendable. Andy Wingo2016-12-121-2/+9
* Import (ice-9 threads) to avoid deprecation warnings•••* fibers/internal.scm: * fibers/repl.scm: Explicitly import (ice-9 threads). Andy Wingo2016-12-122-0/+2
* Merge pull request #4 from vyp/typo•••fibers/internal: comment typosAndy Wingo2016-10-191-2/+2
|\
| * fibers/internal: comment typosxd1le2016-10-041-2/+2
* | create-fiber does not return the fiber•••* fibers/internal.scm (create-fiber): Don't return the fiber. Andy Wingo2016-10-121-2/+1
* | Rename choose to choice•••* fibers/operations.scm (choice-operation): Rename from choose-operation. Andy Wingo2016-10-121-3/+3
* | Internals twiddles•••* fibers/internal.scm (current-scheduler/public): Document. (current-fiber/public): New accessor. (resume-on-timer): Document. * fibers.scm: Adapt to use current-fiber directly from the internals. Remove kill-fiber. Andy Wingo2016-10-121-2/+14
* | Rework internals resume interface•••* fibers/internal.scm (resume-on-fd-events, resume-on-readable-fd) (resume-on-writable-fd, resume-on-timer): Rework primitive resume interface. * fibers.scm: * fibers/timers.scm: Adapt users. Andy Wingo2016-10-122-16/+31
* | Update documentation.Andy Wingo2016-10-124-20/+80
* | Epoll handles event buffer size itself•••* fibers/epoll.scm: Internall handle `maxevents'. * fibers/internal.scm (schedule-runnables-for-next-turn): Update for epoll interface change. Andy Wingo2016-10-122-12/+18
* | fiber-continuation•••* fibers/internal.scm: Rename fiber-data to fiber-continuation. Adapt all users. * fibers/repl.scm: Adapt. Andy Wingo2016-10-122-11/+11
* | Minor fibers/internal cleanups.•••* fibers/internal.scm: Minor cleanups. Andy Wingo2016-10-121-7/+0
* | Move wake facility to epoll module•••* fibers/epoll.scm: Move wake facility here. Note that due to a miscompilation in Guile 2.1.4, this requires a patch from Git master. * fibers/internal.scm: Adapt to change. Andy Wingo2016-10-112-88/+86
* | Lighter fibers•••* fibers/internal.scm: Remove fiber-state; this is managed implicitly now by ensuring that a fiber is only resumed at most once per suspend. We no longer record fiber return values; that should be up to the fiber's init continuation. Replace scheduler inbox with making the runqueue atomic. * fibers.scm (run-fibers): Adapt to run-scheduler change. * fibers/repl.scm (fibers): Adapt to fiber-data change. Andy Wingo2016-10-112-73/+37
* | Runnables refactor•••* fibers/deque.scm (empty-deque?, dequeue-all, dequeue-all!): New interfaces. (update!): New helper. (enqueue!): Use new helper. * fibers/internal.scm: Use deque instead of stack for runnables. Andy Wingo2016-10-112-27/+45
* | Factor out deque implementation•••* fibers/deque.scm: Factor out to helper module. * Makefile.am: Add deque.scm. * fibers/channels.scm: Use (fibers deque). Andy Wingo2016-10-112-48/+77
* | Internal channels refactor•••* fibers/channels.scm: Queue is really a deque; refer to it as such. Andy Wingo2016-10-111-27/+28
|/
* Fix scheduler busy-waiting bug•••* fibers/internal.scm (schedule-runnables-for-next-turn): Fix bug where we were busy-waiting when there were no active fd's. Andy Wingo2016-10-031-9/+11
* Timeout CML operations•••* fibers/timers.scm: New file. * fibers/internal.scm (add-timer!): Take expiry as absolute time. * fibers.scm (fibers): Re-export sleep from (fibers timers). * Makefile.am: Adapt. Andy Wingo2016-10-032-7/+56
* Sleep refactor•••* fibers/internal.scm: Rename sleepers to timers, and be callbacks instead of waking fibers directly. * fibers.scm (sleep): Adapt. Andy Wingo2016-10-031-44/+34
* Reimplement in terms of Parallel Concurrent ML•••* fibers/operations.scm: New file. * fibers/channels.scm: Reimplement in terms of operations (CML events). * tests/basic.scm: Remove channels tests. * tests/channels.scm: Add channels tests. * Makefile.am: Update for new files. Andy Wingo2016-10-032-78/+457
* Add support for ,spawn-fiberAndy Wingo2016-09-202-24/+138
* Add ,fibers command.Andy Wingo2016-09-203-0/+66
* Add fibers and schedulers to namesets•••* fibers/internal.scm (fibers-nameset, schedulers-nameset): Add schedulers and fibers to namesets. Appears to slow down fiber creation by 2X; oh well? Andy Wingo2016-09-191-8/+19
* Add nameset to name fibers and schedulers•••* fibers/nameset.scm: New file. * Makefile.am (SOURCES): Add new file. Andy Wingo2016-09-191-0/+73
* Remove `sleep' export from (fibers internal)•••* fibers/internal.scm: Remove `sleep' export. Andy Wingo2016-09-111-1/+0
* run-fibers returns values from initial thread•••* fibers.scm (run-fibers): * fibers/internal.scm (run-scheduler): If there is an init thunk, keep the scheduler running until the corresponding fiber is finished. Return the values returned from the fiber. * tests/basic.scm (assert-run-fibers-terminates): Return values. (assert-run-fibers-returns): New helper. Use it. Andy Wingo2016-09-101-3/+6