Changeset 3f7e1f24 in mainline for uspace/srv/sysman/job.h
- Timestamp:
- 2019-08-03T08:28:26Z (5 years ago)
- Children:
- 095d03c
- Parents:
- d7c5fc0
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-04-22 17:54:08)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-03 08:28:26)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/job.h
rd7c5fc0 r3f7e1f24 30 30 #define SYSMAN_JOB_H 31 31 32 #include <adt/dyn_array.h> 32 33 #include <adt/list.h> 33 34 #include <atomic.h> 35 #include <stdbool.h> 34 36 35 37 #include "unit.h" 36 38 37 struct job; 38 typedef struct job job_t; 39 39 /** Run state of job */ 40 40 typedef enum { 41 JOB_START 42 } job_type_t; 43 44 typedef enum { 45 JOB_WAITING, 41 JOB_UNQUEUED, /**< Job not in queue yet */ 42 JOB_QUEUED, 43 JOB_DEQUEUED, /**< Job not in queue already */ 46 44 JOB_RUNNING, 47 45 JOB_FINISHED 48 46 } job_state_t; 49 47 48 /** Return value of job */ 49 typedef enum { 50 JOB_OK, 51 JOB_FAILED, 52 JOB_UNDEFINED_ = -1 53 } job_retval_t; 54 50 55 typedef struct { 51 link_t link; 52 job_t *job; 53 } job_link_t; 54 55 /** Job represents pending or running operation on unit */ 56 struct job { 57 /** Link to queue job is in */ 58 link_t link; 59 60 /** List of jobs (job_link_t ) that are blocking the job. */ 61 list_t blocking_jobs; 62 63 /** Reference counter for the job structure. */ 56 link_t job_queue; 64 57 atomic_t refcnt; 65 58 66 job_type_t type;59 unit_state_t target_state; 67 60 unit_t *unit; 68 61 62 /** Jobs that this job is preventing from running */ 63 dyn_array_t blocked_jobs; 64 /** No. of jobs that must finish before this job */ 65 size_t blocking_jobs; 66 /** Any of blocking jobs failed */ 67 bool blocking_job_failed; 68 69 /** See job_state_t */ 69 70 job_state_t state; 70 fibril_mutex_t state_mtx; 71 fibril_condvar_t state_cv; 71 /** See job_retval_t */ 72 job_retval_t retval; 73 } job_t; 72 74 73 /** Return value of the job, defined only when state == JOB_FINISHED */ 74 int retval; 75 }; 75 typedef job_t *job_ptr_t; 76 76 77 77 extern void job_queue_init(void); 78 extern int job_queue_jobs(list_t *); 78 extern int job_queue_add_jobs(dyn_array_t *); 79 extern job_t *job_queue_pop_runnable(void); 79 80 80 extern int job_wait(job_t *); 81 extern int job_create_closure(job_t *, dyn_array_t *); 82 extern job_t *job_create(unit_t *, unit_state_t); 81 83 82 84 extern void job_add_ref(job_t *); 83 85 extern void job_del_ref(job_t **); 84 86 85 extern job_t *job_create(job_type_t type);86 extern int job_add_blocking_job(job_t *, job_t *);87 87 88 extern void job_run(job_t *); 89 extern void job_finish(job_t *); 88 90 #endif
Note:
See TracChangeset
for help on using the changeset viewer.