Changeset c0c388d2 in mainline for uspace/srv/sysman/job.c
- Timestamp:
- 2019-08-03T07:36:48Z (6 years ago)
- Children:
- 4fe7fcb
- Parents:
- 694253c
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-03-16 19:31:17)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-03 07:36:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/job.c
r694253c rc0c388d2 14 14 static fibril_condvar_t job_queue_cv; 15 15 16 static void job_destroy(job_t **); 17 18 16 19 static int job_run_start(job_t *job) 17 20 { … … 72 75 fibril_condvar_broadcast(&job->state_cv); 73 76 fibril_mutex_unlock(&job->state_mtx); 77 78 job_del_ref(&job); 74 79 75 80 return EOK; … … 91 96 * Note that possible use of fibril pool must hold invariant 92 97 * that job is started asynchronously. In the case there exists 93 * circular dependency between jobs, it may attain a deadlock.98 * circular dependency between jobs, it may result in a deadlock. 94 99 */ 95 100 job_t *job = list_get_instance(link, job_t, link); 96 fid_t runner_fibril = fibril_create(job_runner, job); // TODO cast to void*?101 fid_t runner_fibril = fibril_create(job_runner, job); 97 102 fibril_add_ready(runner_fibril); 98 103 } … … 135 140 } 136 141 142 /* Only job dispatcher waits, it's correct to notify one only. */ 137 143 fibril_condvar_signal(&job_queue_cv); 138 144 fibril_mutex_unlock(&job_queue_mtx); … … 160 166 } 161 167 168 void job_add_ref(job_t *job) 169 { 170 atomic_inc(&job->refcnt); 171 } 172 173 void job_del_ref(job_t **job_ptr) 174 { 175 job_t *job = *job_ptr; 176 if (job == NULL) { 177 return; 178 } 179 180 assert(atomic_get(&job->refcnt) > 0); 181 if (atomic_predec(&job->refcnt) == 0) { 182 job_destroy(job_ptr); 183 } 184 } 185 162 186 static void job_init(job_t *job, job_type_t type) 163 187 { … … 166 190 link_initialize(&job->link); 167 191 list_initialize(&job->blocking_jobs); 192 193 /* Start with one reference for the creator */ 194 atomic_set(&job->refcnt, 1); 168 195 169 196 job->type = type; … … 185 212 } 186 213 187 void job_destroy(job_t **job_ptr)214 static void job_destroy(job_t **job_ptr) 188 215 { 189 216 job_t *job = *job_ptr; … … 195 222 job_link_t *jl = list_get_instance(cur_link, job_link_t, link); 196 223 list_remove(cur_link); 224 job_del_ref(&jl->job); 197 225 free(jl); 198 226 }
Note:
See TracChangeset
for help on using the changeset viewer.