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
27b2f7d1
Commit
27b2f7d1
authored
4 weeks ago
by
remi.greub
Browse files
Options
Downloads
Patches
Plain Diff
modifs city.h et main.c
parent
a0777a03
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
G17_bykes/city.h
+15
-14
15 additions, 14 deletions
G17_bykes/city.h
G17_bykes/main.c
+0
-2
0 additions, 2 deletions
G17_bykes/main.c
with
15 additions
and
16 deletions
G17_bykes/city.h
+
15
−
14
View file @
27b2f7d1
...
...
@@ -11,25 +11,26 @@
#include
<semaphore.h>
#define CITY_CAPACITY_MIN 2
#define DEPOT 0
#define USLEEP 0
#define CITY_CAPACITY_MIN 2 //min nb of bikes
#define DEPOT 0 //depot's index
#define USLEEP 1 //activate usleep() = 1 or no = 0
struct
terminal
{
int
nb_bikesParked
;
int
nb_P_waiting
;
sem_t
*
sem_FreeSlot
;
sem_t
*
sem_BikeFree
;
pthread_mutex_t
*
mutex
;
int
nb_bikesParked
;
//number of bikes parked in terminal
int
nb_P_waiting
;
//number of persons waiting in terminal
sem_t
*
sem_FreeSlot
;
//semaphore of the free parking slots -> one each terminal
sem_t
*
sem_BikeFree
;
//semaphore of the free bike -> one each terminal
pthread_mutex_t
*
mutex
;
//mutex -> one for each terminal
};
struct
city
{
int
npersons
;
int
nSlots
;
int
nTerminal
;
int
personsFinished
;
pthread_barrier_t
b
;
struct
terminal
*
terminals
;
int
npersons
;
//nb of persons in the city
int
nSlots
;
//nb of slots for each terminal
int
nTerminal
;
//nb of terminals in the city
int
personsFinished
;
//nb of persons that finished it's iterations
pthread_barrier_t
b
;
//barrier to wait for every person before ending the programm
struct
terminal
*
terminals
;
//all the terminals in the city
};
void
init_city
(
struct
city
*
city
,
int
nbTerminals
,
int
npersons
,
int
nbSlots
);
...
...
This diff is collapsed.
Click to expand it.
G17_bykes/main.c
+
0
−
2
View file @
27b2f7d1
...
...
@@ -29,10 +29,8 @@ int main(int argc, char **argv){
struct
person
*
persons
=
malloc
(
sizeof
(
struct
person
)
*
nbpersons
);
struct
Truck
truck
;
init_city
(
&
city
,
nbterminals
,
nbpersons
,
nbslots
);
printf
(
"COUOCU COUCOU COUCOU %d
\n
"
,
city
.
npersons
);
init_civilians
(
persons
,
&
city
,
nbTravels
);
init_truck
(
&
truck
,
&
city
);
printf
(
"COUOCU COUCOU COUCOU
\n
"
);
if
(
pthread_create
(
threadTruck
,
NULL
,
trucks
,
(
void
*
)
&
truck
)
!=
0
){
perror
(
"thread creation error"
);
...
...
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