authorgravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2019-11-07 16:33:25-06:00
committergravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2019-11-07 16:33:25-06:00
log12e68cbeb636c920475b2420314c23de37689509
tree0e704118e01975303c8199009154d404892d709b
parentf41e58d015eec5fa595b4df8af3cf6a2b598bb02

pthread_sched_yield -> sched_yield


4 files changed, 11 insertions(+), 10 deletions(-)

lib/std/c.zig+2-1
......@@ -158,7 +158,6 @@ pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) c_int;
158158pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) c_int;
159159pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) c_int;
160160pub extern "c" fn pthread_self() pthread_t;
161pub extern "c" fn pthread_yield() c_int;
162161pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) c_int;
163162
164163pub extern "c" fn kqueue() c_int;
......@@ -201,3 +200,5 @@ pub extern "c" fn dn_expand(
201200 exp_dn: [*]u8,
202201 length: c_int,
203202) c_int;
203
204pub extern "c" fn sched_yield() c_int;
lib/std/mutex.zig+1-1
......@@ -100,7 +100,7 @@ else struct {
100100 var value = @atomicLoad(u32, &self.state, .Monotonic);
101101 while (value == Unlocked)
102102 value = @cmpxchgWeak(u32, &self.state, Unlocked, state, .Acquire, .Monotonic) orelse return Held{ .mutex = self };
103 std.os.yield();
103 std.os.sched_yield();
104104 }
105105
106106 // failed to acquire the lock, go to sleep until woken up by `Held.release()`
lib/std/os.zig+7-7
......@@ -3170,12 +3170,12 @@ pub fn dn_expand(
31703170 return error.InvalidDnsPacket;
31713171}
31723172
3173pub fn yield() void {
3174 switch (builtin.os) {
3175 .windows => _ = windows.kernel32.SwitchToThread(),
3176 .linux => _ = assert(linux.sched_yield() == 0),
3177 else => if (builtin.link_libc) {
3178 assert(std.c.pthread_yield() == 0);
3179 },
3173pub fn sched_yield() void {
3174 if (builtin.os == .windows) {
3175 _ = windows.kernel32.SwitchToThread();
3176 } else if (builtin.os == .linux and !builtin.link_libc) {
3177 assert(linux.sched_yield() == 0);
3178 } else if (builtin.link_libc) {
3179 assert(std.c.sched_yield() == 0);
31803180 }
31813181}
lib/std/spinlock.zig+1-1
......@@ -54,7 +54,7 @@ pub const SpinLock = struct {
5454 if (self.iteration < 20) {
5555 SpinLock.yield(self.iteration);
5656 } else if (self.iteration < 24) {
57 os.yield();
57 os.sched_yield();
5858 } else if (self.iteration < 26) {
5959 time.sleep(1 * time.millisecond);
6060 } else {