Changes in kernel/generic/src/synch/syswaitq.c [111b9b9:455241b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/synch/syswaitq.c
r111b9b9 r455241b 48 48 static slab_cache_t *waitq_cache; 49 49 50 static void waitq_destroy(void *arg) 50 typedef struct { 51 kobject_t kobject; 52 waitq_t waitq; 53 } waitq_kobject_t; 54 55 static void waitq_destroy(kobject_t *arg) 51 56 { 52 waitq_ t *wq = (waitq_t *) arg;57 waitq_kobject_t *wq = (waitq_kobject_t *) arg; 53 58 slab_free(waitq_cache, wq); 54 59 } 55 60 56 61 kobject_ops_t waitq_kobject_ops = { 57 .destroy = waitq_destroy 62 .destroy = waitq_destroy, 58 63 }; 59 60 static bool waitq_cap_cleanup_cb(cap_t *cap, void *arg)61 {62 kobject_t *kobj = cap_unpublish(cap->task, cap->handle,63 KOBJECT_TYPE_WAITQ);64 kobject_put(kobj);65 cap_free(cap->task, cap->handle);66 return true;67 }68 64 69 65 /** Initialize the user waitq subsystem */ 70 66 void sys_waitq_init(void) 71 67 { 72 waitq_cache = slab_cache_create("waitq_t", sizeof(waitq_t), 0, NULL, 73 NULL, 0); 74 } 75 76 /** Clean-up all waitq capabilities held by the exiting task */ 77 void sys_waitq_task_cleanup(void) 78 { 79 caps_apply_to_kobject_type(TASK, KOBJECT_TYPE_WAITQ, 80 waitq_cap_cleanup_cb, NULL); 68 waitq_cache = slab_cache_create("syswaitq_t", sizeof(waitq_kobject_t), 69 0, NULL, NULL, 0); 81 70 } 82 71 … … 90 79 sys_errno_t sys_waitq_create(uspace_ptr_cap_waitq_handle_t whandle) 91 80 { 92 waitq_ t *wq= slab_alloc(waitq_cache, FRAME_ATOMIC);93 if (! wq)81 waitq_kobject_t *kobj = slab_alloc(waitq_cache, FRAME_ATOMIC); 82 if (!kobj) 94 83 return (sys_errno_t) ENOMEM; 95 waitq_initialize(wq);96 84 97 kobject_t *kobj = kobject_alloc(0); 98 if (!kobj) { 99 slab_free(waitq_cache, wq); 100 return (sys_errno_t) ENOMEM; 101 } 102 kobject_initialize(kobj, KOBJECT_TYPE_WAITQ, wq); 85 kobject_initialize(&kobj->kobject, KOBJECT_TYPE_WAITQ); 86 waitq_initialize(&kobj->waitq); 103 87 104 88 cap_handle_t handle; 105 89 errno_t rc = cap_alloc(TASK, &handle); 106 90 if (rc != EOK) { 107 slab_free(waitq_cache, wq); 108 kobject_free(kobj); 91 slab_free(waitq_cache, kobj); 109 92 return (sys_errno_t) rc; 110 93 } … … 113 96 if (rc != EOK) { 114 97 cap_free(TASK, handle); 115 kobject_free(kobj); 116 slab_free(waitq_cache, wq); 98 slab_free(waitq_cache, kobj); 117 99 return (sys_errno_t) rc; 118 100 } 119 101 120 cap_publish(TASK, handle, kobj);102 cap_publish(TASK, handle, &kobj->kobject); 121 103 122 104 return (sys_errno_t) EOK; … … 151 133 unsigned int flags) 152 134 { 153 kobject_t *kobj = kobject_get(TASK, whandle, KOBJECT_TYPE_WAITQ); 135 waitq_kobject_t *kobj = 136 (waitq_kobject_t *) kobject_get(TASK, whandle, KOBJECT_TYPE_WAITQ); 154 137 if (!kobj) 155 138 return (sys_errno_t) ENOENT; … … 159 142 #endif 160 143 161 errno_t rc = _waitq_sleep_timeout( kobj->waitq, timeout,144 errno_t rc = _waitq_sleep_timeout(&kobj->waitq, timeout, 162 145 SYNCH_FLAGS_INTERRUPTIBLE | flags); 163 146 … … 166 149 #endif 167 150 168 kobject_put( kobj);151 kobject_put(&kobj->kobject); 169 152 170 153 return (sys_errno_t) rc; … … 179 162 sys_errno_t sys_waitq_wakeup(cap_waitq_handle_t whandle) 180 163 { 181 kobject_t *kobj = kobject_get(TASK, whandle, KOBJECT_TYPE_WAITQ); 164 waitq_kobject_t *kobj = 165 (waitq_kobject_t *) kobject_get(TASK, whandle, KOBJECT_TYPE_WAITQ); 182 166 if (!kobj) 183 167 return (sys_errno_t) ENOENT; 184 168 185 waitq_wake_one( kobj->waitq);169 waitq_wake_one(&kobj->waitq); 186 170 187 kobject_put( kobj);171 kobject_put(&kobj->kobject); 188 172 return (sys_errno_t) EOK; 189 173 }
Note:
See TracChangeset
for help on using the changeset viewer.