chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] set! atomic?


From: Felix
Subject: Re: [Chicken-users] set! atomic?
Date: Wed, 05 Jun 2013 16:13:40 +0200 (CEST)

From: Bryan Vicknair <address@hidden>
Subject: [Chicken-users] set! atomic?
Date: Tue, 4 Jun 2013 19:15:52 -0700

> SRFI-18 states:
> 
>   "Read and write operations on the store (such as reading and writing a
>   variable, an element of a vector or a string) are not required to be atomic.
>   It is an error for a thread to write a location in the store while some 
> other
>   thread reads or writes that same location."
> 
> Is it possible to eval a variable that is in an inconsistent state?  I
> understand that if there are a series of set-car! on a list, then a reader may
> see the list as it is in between any of the set-car! calls.  But is it 
> possible
> that an update to a very large object will ever be interrupted by one thread
> such that other threads will see a broken version?
> 
>   (use srfi-1)
>   (define foo '(1 2 3))
>   (thread-start! (make-thread (lambda () (set! foo (iota 1e8)))))
>   (print foo)
> 
> In the above code, will the primordial thread ever print a list that
> isn't exactly (1 2 3) or (iota 1e8)?

The assignment itself is fully atomic, as is the destructive
modification of any single data-cell like pair-cells, vector-elements
or record-structure slots.


cheers
felix



reply via email to

[Prev in Thread] Current Thread [Next in Thread]