source: mainline/uspace/srv/sysman/job.h@ 4fe7fcb

Last change on this file since 4fe7fcb was 4fe7fcb, checked in by Matthieu Riolo <matthieu.riolo@…>, 6 years ago

Transform unit dependencies to job ordering

  • Property mode set to 100644
File size: 1006 bytes
Line 
1#ifndef SYSMAN_JOB_H
2#define SYSMAN_JOB_H
3
4#include <adt/list.h>
5#include <atomic.h>
6
7#include "unit.h"
8
9struct job;
10typedef struct job job_t;
11
12typedef enum {
13 JOB_START
14} job_type_t;
15
16typedef enum {
17 JOB_WAITING,
18 JOB_RUNNING,
19 JOB_FINISHED
20} job_state_t;
21
22typedef struct {
23 link_t link;
24 job_t *job;
25} job_link_t;
26
27struct job {
28 /** Link to queue job is in */
29 link_t link;
30
31 /** List of jobs (job_link_t ) that are blocking the job. */
32 list_t blocking_jobs;
33
34 /** Reference counter for the job structure. */
35 atomic_t refcnt;
36
37 job_type_t type;
38 unit_t *unit;
39
40 job_state_t state;
41 fibril_mutex_t state_mtx;
42 fibril_condvar_t state_cv;
43
44 /** Return value of the job, defined only when state == JOB_FINISHED */
45 int retval;
46};
47
48extern void job_queue_init(void);
49extern int job_queue_jobs(list_t *);
50
51extern int job_wait(job_t *);
52
53extern void job_add_ref(job_t *);
54extern void job_del_ref(job_t **);
55
56extern job_t *job_create(job_type_t type);
57extern int job_add_blocking_job(job_t *, job_t *);
58
59#endif
Note: See TracBrowser for help on using the repository browser.