Changeset 694253c in mainline
- Timestamp:
- 2019-08-03T07:35:41Z (5 years ago)
- Children:
- c0c388d2
- Parents:
- f42ee6f
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-03-13 02:06:30)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-03 07:35:41)
- Location:
- uspace/srv/sysman
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/Makefile
rf42ee6f r694253c 35 35 configuration.c \ 36 36 dep.c \ 37 job.c \ 37 38 main.c \ 38 39 sysman.c \ -
uspace/srv/sysman/dep.c
rf42ee6f r694253c 10 10 int dep_add_dependency(unit_t *dependant, unit_t *dependency) 11 11 { 12 unit_dependency_t *edge = malloc(sizeof(unit_ t));12 unit_dependency_t *edge = malloc(sizeof(unit_dependency_t)); 13 13 if (edge == NULL) { 14 14 return ENOMEM; 15 15 } 16 link_initialize(&edge->dependants); 17 link_initialize(&edge->dependencies); 18 16 19 // TODO check existence of the edge 17 20 // TODO locking 18 21 // TODO check types and states of connected units 19 /* Do not initalize links as they are immediately inserted into list */20 22 list_append(&edge->dependants, &dependency->dependants); 21 23 list_append(&edge->dependencies, &dependant->dependencies); -
uspace/srv/sysman/main.c
rf42ee6f r694253c 7 7 #include "configuration.h" 8 8 #include "dep.h" 9 #include "job.h" 9 10 #include "sysman.h" 10 11 #include "unit.h" … … 85 86 86 87 configuration_init(); 88 job_queue_init(); 87 89 88 90 /* -
uspace/srv/sysman/sysman.c
rf42ee6f r694253c 1 #include <adt/list.h> 1 2 #include <errno.h> 2 3 4 #include "dep.h" 5 #include "job.h" 3 6 #include "sysman.h" 7 8 static int sysman_create_closure_jobs(unit_t *unit, job_t **entry_job_ptr, 9 list_t *accumulator, job_type_t type) 10 { 11 int rc = EOK; 12 job_t *job = job_create(type); 13 if (job == NULL) { 14 rc = ENOMEM; 15 goto fail; 16 } 17 18 job->unit = unit; 19 // TODO set blocking jobs 20 21 list_foreach(unit->dependencies, dependencies, unit_dependency_t, edge) { 22 rc = sysman_create_closure_jobs(edge->dependency, NULL, 23 accumulator, type); 24 if (rc != EOK) { 25 goto fail; 26 } 27 } 28 29 list_append(&job->link, accumulator); 30 31 if (entry_job_ptr != NULL) { 32 *entry_job_ptr = job; 33 } 34 return EOK; 35 36 fail: 37 job_destroy(&job); 38 return rc; 39 } 4 40 5 41 int sysman_unit_start(unit_t *unit) 6 42 { 7 // satisfy dependencies 8 // start unit (via restarter) 9 return EOK; 43 list_t new_jobs; 44 list_initialize(&new_jobs); 45 46 job_t *job = NULL; 47 int rc = sysman_create_closure_jobs(unit, &job, &new_jobs, JOB_START); 48 if (rc != EOK) { 49 return rc; 50 } 51 52 job_queue_jobs(&new_jobs); 53 54 return job_wait(job); 10 55 } -
uspace/srv/sysman/unit.c
rf42ee6f r694253c 1 1 #include <assert.h> 2 #include <errno.h> 3 #include <fibril_synch.h> 2 4 #include <mem.h> 5 #include <stdio.h> 3 6 #include <stdlib.h> 4 7 … … 9 12 assert(unit); 10 13 11 memset(unit, 0, sizeof(unit)); 14 link_initialize(&unit->units); 15 16 unit->type = type; 17 unit->state = STATE_EMBRYO; 18 fibril_mutex_initialize(&unit->state_mtx); 19 fibril_condvar_initialize(&unit->state_cv); 12 20 13 link_initialize(&unit->units);14 21 list_initialize(&unit->dependants); 15 22 list_initialize(&unit->dependencies); 16 17 unit->type = type;18 unit->state = STATE_EMBRYO;19 23 } 20 24 … … 42 46 *unit = NULL; 43 47 } 48 49 /** Issue request to restarter to start a unit 50 * 51 * Return from this function only means start request was issued. 52 * If you need to wait for real start of the unit, use waiting on state_cv. 53 */ 54 int unit_start(unit_t *unit) 55 { 56 // TODO actually start the unit 57 printf("Starting unit of type %i\n", unit->type); 58 return EOK; 59 } -
uspace/srv/sysman/unit.h
rf42ee6f r694253c 3 3 4 4 #include <adt/list.h> 5 #include <fibril_synch.h> 5 6 6 7 #include "unit_mnt.h" … … 15 16 typedef enum { 16 17 STATE_EMBRYO = 0, 18 STATE_STARTED, 17 19 STATE_STOPPED 18 20 } unit_state_t; … … 22 24 23 25 unit_type_t type; 26 24 27 unit_state_t state; 28 fibril_mutex_t state_mtx; 29 fibril_condvar_t state_cv; 25 30 26 31 list_t dependencies; … … 37 42 extern void unit_destroy(unit_t **); 38 43 44 extern int unit_start(unit_t *); 39 45 40 46 #endif
Note:
See TracChangeset
for help on using the changeset viewer.