Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bandit_Manchot
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
benjamin.sitbon
Bandit_Manchot
Commits
8049520e
Commit
8049520e
authored
4 years ago
by
leonard.beck
Browse files
Options
Downloads
Patches
Plain Diff
fixed leaks
parent
a79ef408
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
one_armed_bandit.c
+6
-1
6 additions, 1 deletion
one_armed_bandit.c
wheel.h
+2
-2
2 additions, 2 deletions
wheel.h
with
8 additions
and
3 deletions
one_armed_bandit.c
+
6
−
1
View file @
8049520e
...
@@ -40,7 +40,7 @@ int stopped_wheels(machine mas){
...
@@ -40,7 +40,7 @@ int stopped_wheels(machine mas){
int
main
()
int
main
()
{
{
int
wheel_turn
=
4
;
int
wheel_turn
=
WHEEL_NB
+
1
;
bool
paid
=
false
;
bool
paid
=
false
;
bool
quit
=
false
;
bool
quit
=
false
;
pthread_t
threads
[
WHEEL_NB
+
1
];
pthread_t
threads
[
WHEEL_NB
+
1
];
...
@@ -114,5 +114,10 @@ int main()
...
@@ -114,5 +114,10 @@ int main()
}
}
}
while
(
!
quit
);
}
while
(
!
quit
);
sem_destroy
(
&
(
mas
.
semaphore
));
for
(
int
i
=
0
;
i
<
WHEEL_NB
;
i
++
)
{
pthread_mutex_destroy
(
&
(
mas
.
wheels
[
i
].
lock
));
}
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
wheel.h
+
2
−
2
View file @
8049520e
...
@@ -12,9 +12,9 @@ typedef struct roue{
...
@@ -12,9 +12,9 @@ typedef struct roue{
int
current_px
;
int
current_px
;
// used to synchronize cache with memory so display is always up to date
// used to synchronize cache with memory so display is always up to date
pthread_mutex_t
lock
;
pthread_mutex_t
lock
;
// used to make the thread wait when the wheel is not spinning
sem_t
*
semaphore
;
sem_t
*
semaphore
;
// used to securely exit the game
bool
*
end
;
bool
*
end
;
}
wheel
;
}
wheel
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment