This repository has been archived by the owner on Mar 20, 2024. It is now read-only.
forked from parallella/pal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p_run.c
62 lines (51 loc) · 1.49 KB
/
p_run.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <pal.h>
/**
*
* Runs(launches) the program 'prog' on all of the members of 'team'.
*
* @param prog Pointer to the program to run that was loaded with p_load()
*
* @param function Name of function within 'prog' to run
*
* @param team Team to run with.
*
* @param start Relative starting processor within team
*
* @param size Total number of processors within team to run
*
* @param nargs Number of arguments to be supplied to 'function'
*
* @param args An array of pointers to function arguments
*
* @param flags Bitfield mask type flags
*
* @return Returns 0 if successful.
*
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "pal_base.h"
#include "pal_base_private.h"
int p_run(p_prog_t prog, const char *function, p_team_t team,
int start, int count, int nargs, const p_arg_t *args, int flags)
{
int err;
struct team *pteam = (struct team *) team;
struct prog *pprog = (struct prog *) prog;
struct dev *pdev;
if (p_ref_is_err(prog) || p_ref_is_err(team))
return -EINVAL;
pdev = pteam->dev;
if (nargs > P_RUN_MAX_ARGS)
return -E2BIG;
err = pdev->dev_ops->run(pdev, pteam, pprog, function, start, count, nargs,
args, flags);
if (err)
return err;
if (!(flags & P_RUN_NONBLOCK))
return p_wait((p_team_t) team); // Inconsistent with flags to this function
return 0;
}