Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
22f89869
Commit
22f89869
authored
Nov 21, 2011
by
Cyrill Gorcunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teste: Add test-shmem-three-async test
Signed-off-by:
Cyrill Gorcunov
<
gorcunov@gmail.com
>
parent
1355c7d2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
Makefile
test/Makefile
+1
-0
test-shmem-three-async.c
test/test-shmem-three-async.c
+76
-0
No files found.
test/Makefile
View file @
22f89869
SRCS
+=
test-counter.c
SRCS
+=
test-rnd-from-file.c
SRCS
+=
test-shmem-async.c
SRCS
+=
test-shmem-three-async.c
OBJS
:=
$
(
patsubst %.c,%.o,
$(SRCS)
)
PROGS
:=
$
(
patsubst %.c,%,
$(SRCS)
)
...
...
test/test-shmem-three-async.c
0 → 100644
View file @
22f89869
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <sched.h>
static
void
*
map1
;
static
void
*
map2
;
int
main
(
int
argc
,
char
*
argv
[])
{
pid_t
pid
;
printf
(
"%s pid %d
\n
"
,
argv
[
0
],
getpid
());
map1
=
mmap
(
NULL
,
1024
,
PROT_READ
|
PROT_WRITE
,
MAP_ANONYMOUS
|
MAP_SHARED
,
-
1
,
0
);
map2
=
mmap
(
NULL
,
1024
,
PROT_READ
|
PROT_WRITE
,
MAP_ANONYMOUS
|
MAP_SHARED
,
-
1
,
0
);
if
(
map1
==
MAP_FAILED
||
map2
==
MAP_FAILED
)
{
printf
(
"%6d: mmap failed
\n
"
,
getpid
());
return
0
;
}
memset
(
map1
,
'-'
,
22
);
((
char
*
)
map1
)[
22
]
=
0
;
memset
(
map2
,
'+'
,
22
);
((
char
*
)
map1
)[
22
]
=
0
;
printf
(
"%6d: Initial shmem1 pattern '%s'
\n
"
,
getpid
(),
(
char
*
)
map1
);
pid
=
fork
();
if
(
pid
==
-
1
)
{
printf
(
"fork1 failed
\n
"
);
return
1
;
}
else
if
(
pid
==
0
)
{
int
cnt
=
0
;
pid
=
fork
();
if
(
pid
==
-
1
)
{
printf
(
"fork2 failed
\n
"
);
exit
(
1
);
}
else
if
(
pid
==
0
)
{
int
num
=
0
;
while
(
1
)
{
printf
(
"%6d: Observed shmem2 pattern '%s'
\n
"
,
getpid
(),
(
char
*
)
map2
);
sprintf
(
map2
,
"shared-mem2-%010d"
,
num
);
sleep
(
1
);
num
+=
2
;
}
}
cnt
=
-
1
;
while
(
1
)
{
cnt
+=
2
;
printf
(
"%6d: Observed shmem1 pattern '%s'
\n
"
,
getpid
(),
(
char
*
)
map1
);
sprintf
(
map1
,
"shared-mem1-%010d"
,
cnt
);
sleep
(
1
);
}
}
else
{
while
(
1
)
{
printf
(
"%6d: Observed shmem1 pattern '%s'
\n
"
,
getpid
(),
(
char
*
)
map1
);
printf
(
"%6d: Observed shmem2 pattern '%s'
\n
"
,
getpid
(),
(
char
*
)
map2
);
sleep
(
1
);
}
}
return
0
;
}
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