forked from parallella/pal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p_barrier.c
38 lines (32 loc) · 1.03 KB
/
p_barrier.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <pal.h>
/**
*
* A barrier for 'team'. The barrier is initialized when the team is
* opened.
*
* @param team Pointer to object containing information about team.
*
* @return Returns 0 if successful.
*
*/
#include <stdio.h>
#include "pal_base.h"
#include "pal_base_private.h"
int p_barrier(p_team_t team)
{
printf("Running p_barrier(%p)\n", team);
/*PUT CODE HERE*/
// 1.Every processor on the team runs this function
// 2.When it hits, decrement the counter location in the "boss node"
// 3.(decrement needs to be an atomic fetch and subtract)
//(alternatively, there could be one entry for each core)
// 4.team members "idle" and wait for signal from boss
// 5.after completion, the boss clears table (resets counter)
// 5.boss processer sends signal back continue signal
// assumptions:
// 1.) the workers have a team structures indicating the upstream root
// structure location
// 2.) this structure gets pushed out durung the p_open call
// 3.)
return (0);
}