Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
nofib
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
9
Issues
9
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
nofib
Commits
c19f3a54
Commit
c19f3a54
authored
Mar 29, 2012
by
dterei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix callback001
parent
ce9eeebe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
smp/callback001/Main.hs
smp/callback001/Main.hs
+6
-6
No files found.
smp/callback001/Main.hs
View file @
c19f3a54
...
@@ -13,27 +13,27 @@ module Main where
...
@@ -13,27 +13,27 @@ module Main where
import
Control.Concurrent
import
Control.Concurrent
import
Control.Monad
import
Control.Monad
import
Foreign.Ptr
import
Data.IORef
import
Data.IORef
import
Foreign.Ptr
import
System.Environment
import
System.Environment
import
System.IO
import
System.IO
main
=
do
main
=
do
[
s
]
<-
getArgs
[
s
]
<-
getArgs
let
n
=
read
s
::
Int
let
n
=
read
s
::
Int
fork
=
if
rtsSupportsBoundThreads
then
forkOS
else
forkIO
sem
<-
newQSemN
0
sem
<-
newQSemN
0
let
fork
=
if
rtsSupportsBoundThreads
then
forkOS
else
forkIO
replicateM
n
$
putStr
"."
>>
hFlush
stdout
>>
fork
(
thread
sem
)
>>
thread
sem
replicateM
n
(
putStr
"."
>>
hFlush
stdout
>>
fork
(
thread
sem
)
>>
thread
sem
)
putChar
'
\n
'
waitQSemN
sem
(
n
*
2
)
waitQSemN
sem
(
n
*
2
)
thread
sem
=
do
thread
sem
=
do
var
<-
newIORef
0
var
<-
newIORef
0
let
f
=
modifyIORef
var
(
1
+
)
let
f
=
modifyIORef
var
(
1
+
)
callC
=<<
mkFunc
f
callC
=<<
mkFunc
f
signalQSemN
sem
1
signalQSemN
sem
1
type
FUNC
=
IO
()
type
FUNC
=
IO
()
foreign
import
ccall
unsafe
"wrapper"
foreign
import
ccall
unsafe
"wrapper"
mkFunc
::
FUNC
->
IO
(
FunPtr
FUNC
)
mkFunc
::
FUNC
->
IO
(
FunPtr
FUNC
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment