Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
G17_bykes_prog_concurrente
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
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
remi.greub
G17_bykes_prog_concurrente
Commits
cbce23f2
Commit
cbce23f2
authored
1 month ago
by
remi.greub
Browse files
Options
Downloads
Patches
Plain Diff
traduction nb_trajets -> travels
parent
3de01481
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
G17_bykes/main.c
+5
-5
5 additions, 5 deletions
G17_bykes/main.c
with
5 additions
and
5 deletions
G17_bykes/main.c
+
5
−
5
View file @
cbce23f2
...
...
@@ -24,7 +24,7 @@ int personsFinished=0;
struct
civilian
{
int
num_thread
;
int
nb_tra
jet
;
int
nb_tra
vels
;
int
max_trajets
;
int
i_cities
;
int
nbcities
;
...
...
@@ -106,7 +106,7 @@ int main(int argc, char **argv){
Civilians
[
i
].
nslotss
=
nbslots
;
Civilians
[
i
].
nbcities
=
nbcities
;
Civilians
[
i
].
num_thread
=
i
;
Civilians
[
i
].
nb_tra
jet
=
0
;
Civilians
[
i
].
nb_tra
vels
=
0
;
Civilians
[
i
].
i_cities
=
(
rand
()
%
(
Civilians
[
i
].
nbcities
-
1
))
+
1
;
if
(
pthread_create
(
&
threadCivilians
[
i
],
NULL
,
civilians
,
(
void
*
)
&
Civilians
[
i
])
!=
0
){
perror
(
"thread creation error"
);
...
...
@@ -158,7 +158,7 @@ void *civilians(void *arg){
int
j
=
0
;
int
val
;
// inside a Mtrajets loop for each civilians
while
(
hab
->
nb_tra
jet
<
hab
->
max_trajets
){
while
(
hab
->
nb_tra
vels
<
hab
->
max_trajets
){
//waits for a bike in cities i
//if(hab->i_cities==4){
sem_getvalue
(
&
sem_FreeSlot
[
hab
->
i_cities
],
&
val
);
...
...
@@ -233,14 +233,14 @@ void *civilians(void *arg){
#endif
//changes his position from cities i = j (j is the new cities)
hab
->
i_cities
=
j
;
hab
->
nb_tra
jet
+=
1
;
hab
->
nb_tra
vels
+=
1
;
}
printf
(
"person %d stops
\n
"
,
hab
->
num_thread
);
pthread_mutex_lock
(
&
mutex
[
hab
->
i_cities
]);
personsFinished
+=
1
;
pthread_mutex_unlock
(
&
mutex
[
hab
->
i_cities
]);
pthread_barrier_wait
(
&
b
);
//printf("machin bidule a passé la barriere !!!! : %d, tot_trajets = %d\n", hab->num_thread, hab->nb_tra
jet
);
//printf("machin bidule a passé la barriere !!!! : %d, tot_trajets = %d\n", hab->num_thread, hab->nb_tra
vels
);
return
NULL
;
}
...
...
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