Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
margo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
18
Issues
18
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
sds
margo
Commits
132a30de
Commit
132a30de
authored
Apr 11, 2016
by
Shane Snyder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add example illustrating sleep functionality
parent
fd88d80a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
21 deletions
+28
-21
examples/Makefile.subdir
examples/Makefile.subdir
+1
-1
examples/sleep.c
examples/sleep.c
+27
-20
No files found.
examples/Makefile.subdir
View file @
132a30de
bin_PROGRAMS
+=
examples/client examples/server examples/server-hang examples/client-timeout
bin_PROGRAMS
+=
examples/client examples/server examples/server-hang examples/client-timeout
examples/sleep
examples_server_SOURCES
=
\
examples/server.c
\
...
...
examples/sleep.c
View file @
132a30de
...
...
@@ -7,11 +7,14 @@
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <stdlib.h>
#include <ctype.h>
#include <abt.h>
#include <abt-snoozer.h>
#include <margo.h>
static
int
use_abt_sleep
;
static
int
use_abt_sleep
=
0
;
static
int
sleep_seconds
=
2
;
static
void
sleep_fn
(
void
*
arg
);
...
...
@@ -27,19 +30,26 @@ int main(int argc, char **argv)
hg_context_t
*
hg_context
;
hg_class_t
*
hg_class
;
if
(
argc
==
1
)
int
arg_ndx
=
1
;
if
(
argc
>
1
)
{
use_abt_sleep
=
0
;
}
else
if
((
argc
==
2
)
&&
(
strcmp
(
argv
[
1
],
"ABT"
)
==
0
))
{
use_abt_sleep
=
1
;
}
else
{
fprintf
(
stderr
,
"Usage: %s [ABT]
\n
"
,
argv
[
0
]);
fprintf
(
stderr
,
"
\t
ABT: use ABT sleep mechanism, rather than POSIX sleep.
\n
"
);
return
(
-
1
);
if
(
isdigit
(
argv
[
1
][
0
]))
{
sleep_seconds
=
atoi
(
argv
[
1
]);
arg_ndx
++
;
}
if
((
arg_ndx
<
argc
)
&&
(
strcmp
(
argv
[
arg_ndx
],
"ABT"
)
==
0
))
{
use_abt_sleep
=
1
;
arg_ndx
++
;
}
if
(
arg_ndx
!=
argc
)
{
fprintf
(
stderr
,
"Usage: %s [sleep_seconds] [ABT]
\n
"
,
argv
[
0
]);
fprintf
(
stderr
,
"
\t
sleep_seconds: number of seconds for each thread to sleep.
\n
"
);
fprintf
(
stderr
,
"
\t
ABT: use ABT sleep mechanism, rather than POSIX sleep.
\n
"
);
return
(
-
1
);
}
}
/* boilerplate HG initialization steps */
...
...
@@ -90,11 +100,8 @@ int main(int argc, char **argv)
}
/* actually start margo */
/* provide argobots pools for driving communication progress and
* executing rpc handlers as well as class and context for Mercury
* communication. The rpc handler pool is null in this example program
* because this is a pure client that will not be servicing rpc requests.
*/
/* use a single pool for progress and sleeper threads */
/* NOTE: no rpc handler threads are needed */
/***************************************/
mid
=
margo_init
(
pool
,
ABT_POOL_NULL
,
hg_context
,
hg_class
);
for
(
i
=
0
;
i
<
4
;
i
++
)
...
...
@@ -147,9 +154,9 @@ static void sleep_fn(void *arg)
int
my_tid
=
*
(
int
*
)
arg
;
if
(
use_abt_sleep
)
margo_thread_sleep
(
2
*
1000
.
0
);
margo_thread_sleep
(
sleep_seconds
*
1000
.
0
);
else
sleep
(
2
);
sleep
(
sleep_seconds
);
printf
(
"TID: %d sleep end
\n
"
,
my_tid
);
...
...
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