Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #6934

Re: Sum server, finished, better, without usleep [Swift]

Newsgroups comp.programming.threads
From Branimir Maksimovic <branimir.maksimovic@icloud.com>
Subject Re: Sum server, finished, better, without usleep [Swift]
References (2 earlier) <RAO6J.64731$jm6.37037@fx07.iad> <9C17J.56040$md6.7378@fx36.iad> <TF47J.12145$fZ.741@fx06.iad> <C887J.146543$rl3.124179@fx45.iad> <v4e7J.55915$nR3.21458@fx38.iad>
Message-ID <SFk7J.64982$6U3.4781@fx43.iad> (permalink)
Organization usenet-news.net
Date 2021-10-06 17:03 +0000

Show all headers | View raw


On 2021-10-06, Branimir Maksimovic <branimir.maksimovic@icloud.com> wrote:
>       while(true){
        usleep(1000) // better not to overheat :P

>       /***
>        * interrestingly CAS doesn't work, because of
>        * some weird Apple memory scheme.
>        * OSAtomicCompareAndSwapPtr: doesn't work
>       */
>       var val:UInt8 = 0
>       repeat {
>           usleep(1)
>           OSMemoryBarrier()
>           val = bval!.pointee!.load(as:UInt8.self)
>       }while ( val == 1 || val == 2)
>       OSMemoryBarrier()
>       bval!.pointee!.storeBytes(of:1,as: UInt8.self)
>       repeat {
>           usleep(1)
>           OSMemoryBarrier()
>           val = bval!.pointee!.load(as:UInt8.self)
>       }while ( val == 2)
>       OSMemoryBarrier()
>       bval!.pointee!.storeBytes(of:2,as: UInt8.self)
>       print("acquired")
    /// payloAD HERE
>       OSMemoryBarrier()
>       bval!.pointee!.storeBytes(of:0,as: UInt8.self)
>       print("releazed\n")
>
>


-- 

7-77-777
Evil Sinner!
to weak you should be meek, and you should brainfuck stronger
https://github.com/rofl0r/chaos-pp

Back to comp.programming.threads | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Sum server [Swift] Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-03 19:07 +0000
  Re: Sum server,improved slightly [Swift] Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-04 04:30 +0000
    Re: Sum server, mutch improved [Swift] Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-05 02:17 +0000
      Re: Sum server, finished [Swift] Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-05 19:22 +0000
        Re: Sum server, finished, bugs corrected, accept now nonblocking as well [Swift] Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-05 22:51 +0000
          Re: Sum server, finished, bugs corrected, accept now nonblocking as well, tweaked [Swift] Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-06 02:49 +0000
            Re: Sum server, finished, better, without usleep [Swift] Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-06 09:34 +0000
              Re: Sum server, finished, better, without usleep [Swift] Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-06 17:03 +0000

csiph-web