/ani/mrses

To get this branch, use:
bzr branch http://suren.me/webbzr/ani/mrses

« back to all changes in this revision

Viewing changes to cell/hw_sched.h

  • Committer: Suren A. Chilingaryan
  • Date: 2010-04-28 04:30:08 UTC
  • Revision ID: csa@dside.dyndns.org-20100428043008-vd9z0nso9axezvlp
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _HW_SCHED_H
 
2
#define _HW_SCHED_H
 
3
 
 
4
typedef struct HWSchedT *HWSched;
 
5
 
 
6
#include "hw_thread.h"
 
7
 
 
8
enum HWSchedModeT {
 
9
    HW_SCHED_MODE_PREALLOCATED = 0,
 
10
    HW_SCHED_MODE_SEQUENTIAL
 
11
};
 
12
typedef enum HWSchedModeT HWSchedMode;
 
13
 
 
14
 
 
15
#define HW_MAX_THREADS 128
 
16
 
 
17
#ifndef HW_HIDE_DETAILS
 
18
#include <pthread.h>
 
19
struct HWSchedT {
 
20
    int status;
 
21
    int started;
 
22
    
 
23
    int n_threads;
 
24
    HWThread thread[HW_MAX_THREADS];
 
25
    
 
26
    int sync_init;
 
27
    pthread_cond_t job_cond, compl_cond;
 
28
    pthread_mutex_t job_cond_mutex, compl_cond_mutex, data_mutex;
 
29
    
 
30
    HWSchedMode mode;
 
31
    int *n_blocks;
 
32
    int *cur_block;
 
33
 
 
34
    int entry;
 
35
    void *ctx;
 
36
};
 
37
typedef struct HWSchedT HWSchedS;
 
38
#endif /* HW_HIDE_DETAILS */
 
39
 
 
40
HWSched hw_sched_create();
 
41
void hw_sched_destroy(HWSched ctx);
 
42
int hw_sched_set_sequential_mode(HWSched ctx, int *n_blocks, int *cur_block);
 
43
int hw_sched_get_chunk(HWSched ctx, int thread_id);
 
44
int hw_sched_schedule_task(HWSched ctx, void *appctx, int entry);
 
45
int hw_sched_wait_task(HWSched ctx);
 
46
 
 
47
#define hw_sched_lock(ctx, type) pthread_mutex_lock(&ctx->type##_mutex)
 
48
#define hw_sched_unlock(ctx, type) pthread_mutex_unlock(&ctx->type##_mutex)
 
49
#define hw_sched_broadcast(ctx, type) pthread_cond_broadcast(&ctx->type##_cond)
 
50
#define hw_sched_signal(ctx, type) pthread_cond_signal(&ctx->type##_cond)
 
51
#define hw_sched_wait(ctx, type) pthread_cond_wait(&ctx->type##_cond, &ctx->type##_cond_mutex)
 
52
 
 
53
#endif /* _HW_SCHED_H */
 
54