Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
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
nexedi
MariaDB
Commits
1febf3a4
Commit
1febf3a4
authored
Jan 17, 2008
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test multiple writers. addresses #7
git-svn-id:
file:///svn/tokudb@1719
c7de825b-a66e-492c-adef-691d508d4ae1
parent
c95f074b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
src/tests/test_db_thread_insert.c
src/tests/test_db_thread_insert.c
+24
-8
No files found.
src/tests/test_db_thread_insert.c
View file @
1febf3a4
...
...
@@ -6,15 +6,25 @@
#include <sys/stat.h>
#include <arpa/inet.h>
#include <db.h>
#include <syscall.h>
#include <pthread.h>
#include "test.h"
static
inline
unsigned
int
getmyid
()
{
#if __linux__
return
syscall
(
__NR_gettid
);
#else
return
getpid
();
#endif
}
typedef
unsigned
int
my_t
;
struct
db_inserter
{
pthread_t
tid
;
DB
*
db
;
my_t
startno
,
endno
;
int
do_exit
;
};
int
db_put
(
DB
*
db
,
my_t
k
,
my_t
v
)
{
...
...
@@ -25,14 +35,14 @@ int db_put(DB *db, my_t k, my_t v) {
void
*
do_inserts
(
void
*
arg
)
{
struct
db_inserter
*
mywork
=
(
struct
db_inserter
*
)
arg
;
printf
(
"%lu:do_inserts:start:%d-%d
\n
"
,
(
unsigned
long
)
pthread_self
(),
mywork
->
startno
,
mywork
->
endno
);
if
(
verbose
)
printf
(
"%lu:%u:do_inserts:start:%u-%u
\n
"
,
(
unsigned
long
)
pthread_self
(),
getmyid
(),
mywork
->
startno
,
mywork
->
endno
);
my_t
i
;
for
(
i
=
mywork
->
startno
;
i
<
mywork
->
endno
;
i
++
)
{
int
r
=
db_put
(
mywork
->
db
,
htonl
(
i
),
i
);
assert
(
r
==
0
);
}
printf
(
"%lu:do_inserts:end
\n
"
,
(
unsigned
long
)
pthread_self
());
pthread_exit
(
0
);
if
(
verbose
)
printf
(
"%lu:%u:do_inserts:end
\n
"
,
(
unsigned
long
)
pthread_self
(),
getmyid
());
if
(
mywork
->
do_exit
)
pthread_exit
(
arg
);
return
0
;
}
...
...
@@ -90,17 +100,23 @@ int main(int argc, char *argv[]) {
for
(
i
=
0
;
i
<
nthreads
;
i
++
)
{
work
[
i
].
db
=
db
;
work
[
i
].
startno
=
i
*
n
/
nthreads
;
work
[
i
].
endno
=
work
[
i
].
startno
+
n
/
nthreads
;
work
[
i
].
startno
=
i
*
(
n
/
nthreads
);
work
[
i
].
endno
=
work
[
i
].
startno
+
(
n
/
nthreads
);
work
[
i
].
do_exit
=
1
;
if
(
i
+
1
==
nthreads
)
work
[
i
].
endno
=
n
;
}
for
(
i
=
0
;
i
<
nthreads
;
i
++
)
{
if
(
verbose
)
printf
(
"pid:%u
\n
"
,
getpid
());
for
(
i
=
1
;
i
<
nthreads
;
i
++
)
{
r
=
pthread_create
(
&
work
[
i
].
tid
,
0
,
do_inserts
,
&
work
[
i
]);
assert
(
r
==
0
);
}
for
(
i
=
0
;
i
<
nthreads
;
i
++
)
{
work
[
0
].
do_exit
=
0
;
do_inserts
(
&
work
[
0
]);
for
(
i
=
1
;
i
<
nthreads
;
i
++
)
{
void
*
ret
;
r
=
pthread_join
(
work
[
i
].
tid
,
&
ret
);
assert
(
r
==
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