Changeset 3f7e1f24 in mainline for uspace/srv/sysman/job.h


Ignore:
Timestamp:
2019-08-03T08:28:26Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
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)
Message:

sysman: Refactored job manipulation (event loop + one main fibril)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/sysman/job.h

    rd7c5fc0 r3f7e1f24  
    3030#define SYSMAN_JOB_H
    3131
     32#include <adt/dyn_array.h>
    3233#include <adt/list.h>
    3334#include <atomic.h>
     35#include <stdbool.h>
    3436
    3537#include "unit.h"
    3638
    37 struct job;
    38 typedef struct job job_t;
    39 
     39/** Run state of job */
    4040typedef 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 */
    4644        JOB_RUNNING,
    4745        JOB_FINISHED
    4846} job_state_t;
    4947
     48/** Return value of job */
     49typedef enum {
     50        JOB_OK,
     51        JOB_FAILED,
     52        JOB_UNDEFINED_ = -1
     53} job_retval_t;
     54
    5055typedef 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;
    6457        atomic_t refcnt;
    6558
    66         job_type_t type;
     59        unit_state_t target_state;
    6760        unit_t *unit;
    6861
     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 */
    6970        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;
    7274
    73         /** Return value of the job, defined only when state == JOB_FINISHED */
    74         int retval;
    75 };
     75typedef job_t *job_ptr_t;
    7676
    7777extern void job_queue_init(void);
    78 extern int job_queue_jobs(list_t *);
     78extern int job_queue_add_jobs(dyn_array_t *);
     79extern job_t *job_queue_pop_runnable(void);
    7980
    80 extern int job_wait(job_t *);
     81extern int job_create_closure(job_t *, dyn_array_t *);
     82extern job_t *job_create(unit_t *, unit_state_t);
    8183
    8284extern void job_add_ref(job_t *);
    8385extern void job_del_ref(job_t **);
    8486
    85 extern job_t *job_create(job_type_t type);
    86 extern int job_add_blocking_job(job_t *, job_t *);
    8787
     88extern void job_run(job_t *);
     89extern void job_finish(job_t *);
    8890#endif
Note: See TracChangeset for help on using the changeset viewer.