Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
e.maksimov2
Homeworks
Commits
70d8a556
Commit
70d8a556
authored
10 months ago
by
e.maksimov2
Browse files
Options
Download
Email Patches
Plain Diff
Upload New File
parent
8a7ce4c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
Homeworks_2Semestr/ADTQueue_withMutex/main.c
Homeworks_2Semestr/ADTQueue_withMutex/main.c
+37
-0
No files found.
Homeworks_2Semestr/ADTQueue_withMutex/main.c
0 → 100644
View file @
70d8a556
#include <pthread.h>
#include "ADTQueue.h"
queue
*
q
;
pthread_mutex_t
m
;
void
*
getData
(
void
*
args
)
{
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
push
(
q
,
(
void
*
)
i
);
}
return
NULL
;
}
int
main
()
{
q
=
init
(
1000
,
sizeof
(
int
));
pthread_t
first
,
second
;
int
id1
=
1
,
id2
=
2
;
pthread_mutex_init
(
&
m
,
NULL
);
q
->
m
=
m
;
pthread_create
(
&
first
,
NULL
,
getData
,
&
id1
);
pthread_create
(
&
second
,
NULL
,
getData
,
&
id2
);
pthread_join
(
first
,
NULL
);
pthread_join
(
second
,
NULL
);
pthread_mutex_destroy
(
&
m
);
pop
(
q
);
iterate
(
q
);
clean
(
q
);
return
0
;
}
This diff is collapsed.
Click to expand it.
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