/
gw_job_pool.h
81 lines (54 loc) · 2.57 KB
/
gw_job_pool.h
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2006 GridWay Team, Distributed Systems Architecture */
/* Group, Universidad Complutense de Madrid */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
#ifndef _GW_JOB_POOL_H
#define _GW_JOB_POOL_H
#include <pthread.h>
#include "gw_job.h"
#include "gw_em_mad.h"
#include "gw_dm_mad.h"
#include "gw_action.h"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
typedef struct gw_job_pool_s
{
pthread_mutex_t mutex;
int number_of_jobs;
int last_job_id;
gw_job_t **pool;
} gw_job_pool_t;
typedef struct gw_job_dep_matrix_s
{
pthread_mutex_t mutex;
int **deps;
} gw_job_dep_matrix_t;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
gw_job_pool_t * gw_job_pool_init();
void gw_job_pool_finalize();
int gw_job_pool_allocate ();
int gw_job_pool_allocate_by_id (int job_id);
void gw_job_pool_free (int job_id);
gw_job_t* gw_job_pool_get (int job_id, int lock);
int gw_job_pool_get_num_jobs();
int gw_job_pool_em_recover (gw_em_mad_t * em_mad);
int gw_job_pool_dm_recover (gw_dm_mad_t * em_mad);
void gw_job_pool_tm_recover (gw_am_t *dm_am);
void gw_job_pool_dep_check(int job_id);
void gw_job_pool_dep_set(int job_id, int *deps);
void gw_job_pool_dep_cp (const int * src, int **dst);
void gw_job_pool_dep_consistency();
#endif