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