what does "atomically#" mean?
Any idea was the atomically# mean in the following code? atomically :: STM a -> IO a atomically (STM m) = IO (\s -> (*atomically# *m) s ) Code is from GHC.Conc module http://www.haskell.org/ghc/docs/6.6/html/libraries/base/GHC-Conc.html daryoush
dmehrtash:
Any idea was the atomically# mean in the following code?
atomically :: STM a -> IO a atomically (STM m) = IO (\s -> (atomically# m) s )
Code is from GHC.Conc module [1]http://www.haskell.org/ghc/docs/6.6/html/libraries/base/GHC-Conc.html
It is a primitive hook into the runtime, where transactional memory is implemented. It is documented in the primops module in the GHC source, $ cd ghc/compiler/prelude/ ------------------------------------------------------------------------ section "STM-accessible Mutable Variables" ------------------------------------------------------------------------ primtype TVar# s a primop AtomicallyOp "atomically#" GenPrimOp (State# RealWorld -> (# State# RealWorld, a #) ) -> State# RealWorld -> (# State# RealWorld, a #) with out_of_line = True has_side_effects = True primop RetryOp "retry#" GenPrimOp State# RealWorld -> (# State# RealWorld, a #) with out_of_line = True has_side_effects = True Along with other primitives like: ------------------------------------------------------------------------ section "Parallelism" ------------------------------------------------------------------------ primop ParOp "par#" GenPrimOp a -> Int# with -- Note that Par is lazy to avoid that the sparked thing -- gets evaluted strictly, which it should *not* be has_side_effects = True -- Don
I like to look at the code where the runtime detects a TVar, inside an atomic block, has been changed by another thread and hence it aborts the atomic operation. Any suggestion as to where I would find the code? daryoush On Sun, Dec 7, 2008 at 10:48 PM, Don Stewart <dons@galois.com> wrote:
dmehrtash:
Any idea was the atomically# mean in the following code?
atomically :: STM a -> IO a atomically (STM m) = IO (\s -> (atomically# m) s )
Code is from GHC.Conc module [1] http://www.haskell.org/ghc/docs/6.6/html/libraries/base/GHC-Conc.html
It is a primitive hook into the runtime, where transactional memory is implemented.
It is documented in the primops module in the GHC source,
$ cd ghc/compiler/prelude/
------------------------------------------------------------------------ section "STM-accessible Mutable Variables" ------------------------------------------------------------------------
primtype TVar# s a
primop AtomicallyOp "atomically#" GenPrimOp (State# RealWorld -> (# State# RealWorld, a #) ) -> State# RealWorld -> (# State# RealWorld, a #) with out_of_line = True has_side_effects = True
primop RetryOp "retry#" GenPrimOp State# RealWorld -> (# State# RealWorld, a #) with out_of_line = True has_side_effects = True
Along with other primitives like:
------------------------------------------------------------------------ section "Parallelism" ------------------------------------------------------------------------
primop ParOp "par#" GenPrimOp a -> Int# with -- Note that Par is lazy to avoid that the sparked thing -- gets evaluted strictly, which it should *not* be has_side_effects = True
-- Don
-- Daryoush Weblog: http://perlustration.blogspot.com/
That code is in <ghc root>/rts/STM.c -- ryan 2009/1/30 Daryoush Mehrtash <dmehrtash@gmail.com>:
I like to look at the code where the runtime detects a TVar, inside an atomic block, has been changed by another thread and hence it aborts the atomic operation. Any suggestion as to where I would find the code?
daryoush
On Sun, Dec 7, 2008 at 10:48 PM, Don Stewart <dons@galois.com> wrote:
dmehrtash:
Any idea was the atomically# mean in the following code?
atomically :: STM a -> IO a atomically (STM m) = IO (\s -> (atomically# m) s )
Code is from GHC.Conc module
[1]http://www.haskell.org/ghc/docs/6.6/html/libraries/base/GHC-Conc.html
It is a primitive hook into the runtime, where transactional memory is implemented.
It is documented in the primops module in the GHC source,
$ cd ghc/compiler/prelude/
------------------------------------------------------------------------ section "STM-accessible Mutable Variables"
------------------------------------------------------------------------
primtype TVar# s a
primop AtomicallyOp "atomically#" GenPrimOp (State# RealWorld -> (# State# RealWorld, a #) ) -> State# RealWorld -> (# State# RealWorld, a #) with out_of_line = True has_side_effects = True
primop RetryOp "retry#" GenPrimOp State# RealWorld -> (# State# RealWorld, a #) with out_of_line = True has_side_effects = True
Along with other primitives like:
------------------------------------------------------------------------ section "Parallelism" ------------------------------------------------------------------------
primop ParOp "par#" GenPrimOp a -> Int# with -- Note that Par is lazy to avoid that the sparked thing -- gets evaluted strictly, which it should *not* be has_side_effects = True
-- Don
-- Daryoush
Weblog: http://perlustration.blogspot.com/
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
I am having hard time making sense of GHC.Conc. Is there a writeup that describes the significance of "#", or the meaning of "primOp" and "primType"? Thanks Daryoush On Sun, Dec 7, 2008 at 11:48 PM, Don Stewart <dons@galois.com> wrote:
dmehrtash:
Any idea was the atomically# mean in the following code?
atomically :: STM a -> IO a atomically (STM m) = IO (\s -> (atomically# m) s )
Code is from GHC.Conc module [1] http://www.haskell.org/ghc/docs/6.6/html/libraries/base/GHC-Conc.html
It is a primitive hook into the runtime, where transactional memory is implemented.
It is documented in the primops module in the GHC source,
$ cd ghc/compiler/prelude/
------------------------------------------------------------------------ section "STM-accessible Mutable Variables" ------------------------------------------------------------------------
primtype TVar# s a
primop AtomicallyOp "atomically#" GenPrimOp (State# RealWorld -> (# State# RealWorld, a #) ) -> State# RealWorld -> (# State# RealWorld, a #) with out_of_line = True has_side_effects = True
primop RetryOp "retry#" GenPrimOp State# RealWorld -> (# State# RealWorld, a #) with out_of_line = True has_side_effects = True
Along with other primitives like:
------------------------------------------------------------------------ section "Parallelism" ------------------------------------------------------------------------
primop ParOp "par#" GenPrimOp a -> Int# with -- Note that Par is lazy to avoid that the sparked thing -- gets evaluted strictly, which it should *not* be has_side_effects = True
-- Don
This might be of some help: http://www.haskell.org/ghc/docs/6.10.1/html/users_guide/syntax-extns.html Daryoush Mehrtash wrote:
I am having hard time making sense of GHC.Conc. Is there a writeup that describes the significance of "#", or the meaning of "primOp" and "primType"?
participants (4)
-
Daryoush Mehrtash -
Don Stewart -
Martijn van Steenbergen -
Ryan Ingram