Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Assignment Parallel Graph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Alexandru BRĂSLAŞU
Assignment Parallel Graph
Commits
9c748586
Commit
9c748586
authored
1 year ago
by
Alexandru BRĂSLAŞU
Browse files
Options
Downloads
Patches
Plain Diff
Tema
parent
54f2dab2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#44265
canceled
1 year ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/os_threadpool.c
+7
-1
7 additions, 1 deletion
src/os_threadpool.c
src/parallel.c
+1
-1
1 addition, 1 deletion
src/parallel.c
with
8 additions
and
2 deletions
src/os_threadpool.c
+
7
−
1
View file @
9c748586
...
...
@@ -70,8 +70,10 @@ os_task_t *dequeue_task(os_threadpool_t *tp)
return
NULL
;
pthread_mutex_lock
(
&
tp
->
mutexCoada
);
pthread_cond_broadcast
(
&
tp
->
WakeUp
);
while
(
queue_is_empty
(
tp
)
&&
!
tp
->
stop
)
while
(
queue_is_empty
(
tp
)
&&
!
tp
->
stop
)
{
pthread_cond_wait
(
&
tp
->
Wait
,
&
tp
->
mutexCoada
);
pthread_cond_broadcast
(
&
tp
->
WakeUp
);
}
if
(
tp
->
stop
)
{
pthread_mutex_unlock
(
&
tp
->
mutexCoada
);
return
NULL
;
...
...
@@ -108,13 +110,17 @@ void wait_for_completion(os_threadpool_t *tp)
/* TODO: Wait for all worker threads. Use synchronization. */
if
(
tp
==
NULL
)
return
;
pthread_mutex_lock
(
&
tp
->
mutexCoada
);
while
(
tp
->
verifProcessing
())
pthread_cond_wait
(
&
tp
->
WakeUp
,
&
tp
->
mutexCoada
);
tp
->
stop
=
1
;
pthread_mutex_unlock
(
&
tp
->
mutexCoada
);
pthread_mutex_lock
(
&
tp
->
mutexCoada
);
while
(
tp
->
threadsOut
<
tp
->
num_threads
)
{
pthread_cond_broadcast
(
&
tp
->
Wait
);
pthread_cond_wait
(
&
tp
->
WakeUp
,
&
tp
->
mutexCoada
);
}
pthread_mutex_unlock
(
&
tp
->
mutexCoada
);
/* Join all worker threads. */
for
(
unsigned
int
i
=
0
;
i
<
tp
->
num_threads
;
i
++
)
pthread_join
(
tp
->
threads
[
i
],
NULL
);
...
...
This diff is collapsed.
Click to expand it.
src/parallel.c
+
1
−
1
View file @
9c748586
...
...
@@ -39,7 +39,7 @@ static void process_node(unsigned int idx)
/* TODO: Implement thread-pool based processing of graph. */
pthread_mutex_lock
(
&
tp
->
mutexSuma
);
sum
+=
graph
->
nodes
[
idx
]
->
info
;
pthread_mutex_
un
lock
(
&
tp
->
mutexSuma
);
pthread_mutex_lock
(
&
tp
->
mutexSuma
);
graph
->
visited
[
idx
]
=
DONE
;
for
(
unsigned
int
i
=
0
;
i
<
graph
->
nodes
[
idx
]
->
num_neighbours
;
++
i
)
{
if
(
graph
->
visited
[
graph
->
nodes
[
idx
]
->
neighbours
[
i
]]
==
NOT_VISITED
)
{
...
...
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