Commit Graph

19 Commits

Author SHA1 Message Date
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
gingerBill
2b080dbbc2 sync_atomic_* make most ordering parameters compile-time constant 2019-05-28 15:57:06 +01:00
gingerBill
fdb60b2d51 Improve package strings 2019-03-15 18:30:39 +00:00
gingerBill
79b585ada8 Add minor additions to mem, sync, and sys/win32 2019-02-21 21:45:33 +00:00
gingerBill
72f4186b21 Fix atomic.odin 2018-10-20 12:55:48 +01:00
gingerBill
3742d9e7e9 Move atomic intrinsics to the new built-in package intrinsics 2018-10-20 10:44:02 +01:00
gingerBill
4ac1218bf8 sync atomics "wrapper" procedures 2018-10-17 21:43:05 +01:00
gingerBill
0858ae2024 Add utf8_to_ucs2 for package win32 so that the wide procedures can used by default 2018-08-30 10:59:46 +01:00
gingerBill
5f20e04259 Fix on *nix 2018-07-01 17:14:22 +01:00
gingerBill
e9e7ce2606 Allow .allocator for dynamic arrays; Add mem.Pool 2018-06-12 19:10:14 +01:00
gingerBill
12b870ba66 Use const & for Array<AstNode *> parameters 2018-06-03 10:30:31 +01:00
gingerBill
5b6770f3d2 Parse directories to be packages 2018-05-21 20:47:52 +01:00