Commit Graph

61 Commits

Author SHA1 Message Date
gingerBill
ffffb04d85 Remove unused import 2021-04-27 17:21:52 +01:00
gingerBill
17390cd317 Implement sync2.Recursive_Mutex using WaitOnAddress and friends on Windows 2021-04-27 17:19:12 +01:00
gingerBill
7ac80544a1 Max sync2.Sema on windows be i32 for the counter internally. 2021-04-27 16:59:25 +01:00
gingerBill
96b60d8779 Reimplement sync2.Sema on windows with WaitOnAddress primitives 2021-04-27 16:56:11 +01:00
gingerBill
158e4c0b6c Add @(cold) tag 2021-04-22 10:35:37 +01:00
gingerBill
05a181d719 Fix style issues; Use new attribute @(cold) where appropriate in the new sync package 2021-04-14 20:19:02 +01:00
gingerBill
bee8beb2c9 Default to pthreads in sync2 for *nix 2021-04-13 19:04:44 +01:00
gingerBill
4fb4ada2c7 Update sync2 to just use atomic intrinsics rather than the parapoly wrappers 2021-04-12 15:22:40 +01:00
gingerBill
1156bd9dd0 Remove thread stuff from sync2; Cleanup package thread 2021-04-11 18:25:56 +01:00
gingerBill
52c193316b Add Thread stuff to new sync package 2021-04-11 15:36:55 +01:00
gingerBill
2db1fe7429 New redesign of core:sync (stored under core:sync/sync2 for the time being) 2021-04-11 15:18:28 +01:00
gingerBill
b727b6438b Minimize unneeded casts 2021-03-03 14:31:17 +00:00
gingerBill
aa93305015 Replace usage of inline proc with #force_inline proc in the core library 2021-02-23 16:14:47 +00:00
gingerBill
98ad912509 Fix typo 2020-12-27 16:16:04 +00:00
gingerBill
95b94a0f56 Fix sync.Channel code; add thread.run_with_poly_data and run_with_poly_data(2|3|4) procedures 2020-11-10 15:00:40 +00:00
gingerBill
eea3a1ecd3 Improve sync.Channel to encode the direction into the type 2020-11-09 13:05:02 +00:00
Christian Seibold
577be4a8ae Get Odin compiling and produced exe's running on FreeBSD 2020-09-14 15:22:35 -05:00
gingerBill
6158a49618 Make sync.atomic_* operations use when statements instead of switch; Make #panic diverging 2020-08-16 12:34:12 +01:00
gingerBill
804b96a985 Remove unused entities 2020-08-02 15:11:21 +01:00
gingerBill
9cc20954a3 Add sys/windows/synchronization.odin 2020-08-02 15:07:52 +01:00
gingerBill
91ff3e5bca Add sync/channel_*.odin files 2020-08-02 15:05:04 +01:00
gingerBill
6d032e6f1a Update package sync 2020-08-02 15:01:17 +01:00
gingerBill
3a1492fc99 Add sync.Wait_Group 2020-07-15 00:25:37 +01:00
gingerBill
96ad6d2084 Improve sync.Channel behaviour 2020-07-14 18:43:50 +01:00
gingerBill
6565a49e34 Remove fmt from sync/channel.odin 2020-07-14 16:39:47 +01:00
gingerBill
fc65aee307 Update sync.Channel 2020-07-14 16:37:29 +01:00
gingerBill
94ba182691 Add sync.Benaphore 2020-07-08 23:16:54 +01:00
gingerBill
86448ee044 Add raw_data to replace cases in which &x[0] was used 2020-06-29 15:58:24 +01:00
gingerBill
56a52a1d06 Add sync.condition_wait_for_timeout for unix 2020-06-27 12:21:31 +01:00
gingerBill
9fdebebd28 Add sync.Barrier; Add sync.Blocking_Mutex for unix 2020-06-27 11:23:37 +01:00
gingerBill
2b18f43b65 Update sys/windows; Add sync.Blocking_Mutex (windows only at the moment) 2020-06-27 00:59:40 +01:00
gingerBill
b5f9c95ce7 Remove foreign import for -vet 2020-06-26 20:33:47 +01:00
gingerBill
231f91304a Keep previous behaviour for sync but move to sys/windows 2020-06-26 20:30:33 +01:00
gingerBill
d7b3f3a0e7 Revert sync_windows.odin 2020-06-26 20:22:48 +01:00
gingerBill
b633a42bc2 Revert channel.odin 2020-06-26 19:16:17 +01:00
gingerBill
6bd05ef5d7 Begin migration from sys/win32 to sys/windows 2020-06-26 19:11:34 +01:00
gingerBill
2a598aa061 Update sync.Channel 2020-06-22 17:45:01 +01:00
gingerBill
0db1ebb4e5 -vet sync/channel.odin 2020-06-22 16:01:26 +01:00
gingerBill
f00123742c Add experimental sync.Channel 2020-06-22 15:54:35 +01:00
gingerBill
0ab356aa4e Fix sync and thread on *nix 2020-06-22 13:32:58 +01:00
gingerBill
9495e3d10c Update sync.Condition to require a ^sync.Mutex on init 2020-06-22 13:24:51 +01:00
gingerBill
59a0bbb385 Improve termination rules checking for missing return; Make diverging procedure -> ! be terminators 2020-06-06 15:16:24 +01:00
gingerBill
e0a242e9a1 Enforce explicit context definition for procedure calls 2020-05-14 13:44:28 +01:00
Tetralux
e7e936f480 Merge branch 'master' into fix-sync-badopt 2020-04-22 06:12:41 +01:00
Tetralux
3afa2736b7 Fix potential bad optimization bug in sync.Ticket_Mutex
When locking, we were not loading m.serving atomically and so the optimizer
could have hoisted the check out of the loop, thus resulting in an infinite loop.
2020-04-21 17:04:29 +00:00
Tetralux
8dd1b61aa2 sync.yield_processor -> sync.cpu_relax; have it call intrinsics.cpu_relax 2020-04-21 16:07:18 +00:00
KTRosenberg
d017b5de9d replaced pthread_yield with ssched_yield, fixed semaphore post:q 2020-01-02 16:25:48 -05:00
gingerBill
3bd00fd6b7 Add thread.Pool with example in demo.odin; Update linalg to support handness changes for projection matrices 2020-01-02 15:07:12 +00:00
gingerBill
d1c9fd4e01 Implement #complete switch by default, replace with #partial switch #511 2019-12-22 12:03:48 +00:00
Tetralux
99121d6ff2 Implement core:thread and core:sync on Unix using pthreads
Also do some cleanup and refactoring of the thread, sync and time APIs.

- remove 'semaphore_release' because 'post' and 'wait' is easier to understand

- change 'semaphore_wait' to '*_wait_for' to match Condition

- pthreads can be given a stack, but doing so requires the user to set up the guard
  pages manually. BE WARNED. The alignment requirements of the stack are also
  platform-dependant; it may need to be page size aligned on some systems.
  Unclear which systems, however. See 'os.get_page_size', and 'mem.make_aligned'.
  HOWEVER: I was unable to get custom stacks with guard pages working reliably,
  so while you can do it, the API does not support it.

- add 'os.get_page_size', 'mem.make_aligned', and 'mem.new_aligned'.

- removed thread return values because windows and linux are not consistent; windows returns 'i32'
  and pthreads return 'void*'; besides which, if you really wanted to communicate how the
  thread exited, you probably wouldn't do it with the thread's exit code.

- fixed 'thread.is_done' on Windows; it didn't report true immediately after calling 'thread.join'.

- moved time related stuff out of 'core:os' to 'core:time'.

- add 'mem.align_backward'

- fixed default allocator alignment
  The heap on Windows, and calloc on Linux, both have no facility to request alignment.
  It's a bit of hack, but the heap_allocator now overallocates; `size + alignment` bytes,
  and aligns things to at least 2.
  It does both of these things to ensure that there is at least two bytes before the payload,
  which it uses to store how much padding it needed to insert in order to fulfil the alignment
  requested.

- make conditions more sane by matching the Windows behaviour.
  The fact that they were signalled now lingers until a thread tries to wait,
  causing them to just pass by uninterrupted, without sleeping or locking the
  underlying mutex, as it would otherwise need to do.
  This means that a thread no longer has to be waiting in order to be signalled, which
  avoids timing bugs that causes deadlocks that are hard to debug and fix.
  See the comment on the `sync.Condition.flag` field.

- add thread priority: `thread.create(worker_proc, .High)`
2019-12-01 00:46:23 +00:00