Changeset 455241b in mainline for kernel/generic/src/synch/syswaitq.c
- Timestamp:
- 2025-01-16T19:29:20Z (13 days ago)
- Children:
- 74353920
- Parents:
- df721df
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-01-16 19:23:14)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-01-16 19:29:20)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/synch/syswaitq.c
rdf721df 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 64 … … 61 66 void sys_waitq_init(void) 62 67 { 63 waitq_cache = slab_cache_create(" waitq_t", sizeof(waitq_t), 0, NULL,64 NULL, 0);68 waitq_cache = slab_cache_create("syswaitq_t", sizeof(waitq_kobject_t), 69 0, NULL, NULL, 0); 65 70 } 66 71 … … 74 79 sys_errno_t sys_waitq_create(uspace_ptr_cap_waitq_handle_t whandle) 75 80 { 76 waitq_ t *wq= slab_alloc(waitq_cache, FRAME_ATOMIC);77 if (! wq)81 waitq_kobject_t *kobj = slab_alloc(waitq_cache, FRAME_ATOMIC); 82 if (!kobj) 78 83 return (sys_errno_t) ENOMEM; 79 waitq_initialize(wq);80 84 81 kobject_t *kobj = kobject_alloc(0); 82 if (!kobj) { 83 slab_free(waitq_cache, wq); 84 return (sys_errno_t) ENOMEM; 85 } 86 kobject_initialize(kobj, KOBJECT_TYPE_WAITQ, wq); 85 kobject_initialize(&kobj->kobject, KOBJECT_TYPE_WAITQ); 86 waitq_initialize(&kobj->waitq); 87 87 88 88 cap_handle_t handle; 89 89 errno_t rc = cap_alloc(TASK, &handle); 90 90 if (rc != EOK) { 91 slab_free(waitq_cache, wq); 92 kobject_free(kobj); 91 slab_free(waitq_cache, kobj); 93 92 return (sys_errno_t) rc; 94 93 } … … 97 96 if (rc != EOK) { 98 97 cap_free(TASK, handle); 99 kobject_free(kobj); 100 slab_free(waitq_cache, wq); 98 slab_free(waitq_cache, kobj); 101 99 return (sys_errno_t) rc; 102 100 } 103 101 104 cap_publish(TASK, handle, kobj);102 cap_publish(TASK, handle, &kobj->kobject); 105 103 106 104 return (sys_errno_t) EOK; … … 135 133 unsigned int flags) 136 134 { 137 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); 138 137 if (!kobj) 139 138 return (sys_errno_t) ENOENT; … … 143 142 #endif 144 143 145 errno_t rc = _waitq_sleep_timeout( kobj->waitq, timeout,144 errno_t rc = _waitq_sleep_timeout(&kobj->waitq, timeout, 146 145 SYNCH_FLAGS_INTERRUPTIBLE | flags); 147 146 … … 150 149 #endif 151 150 152 kobject_put( kobj);151 kobject_put(&kobj->kobject); 153 152 154 153 return (sys_errno_t) rc; … … 163 162 sys_errno_t sys_waitq_wakeup(cap_waitq_handle_t whandle) 164 163 { 165 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); 166 166 if (!kobj) 167 167 return (sys_errno_t) ENOENT; 168 168 169 waitq_wake_one( kobj->waitq);169 waitq_wake_one(&kobj->waitq); 170 170 171 kobject_put( kobj);171 kobject_put(&kobj->kobject); 172 172 return (sys_errno_t) EOK; 173 173 }
Note:
See TracChangeset
for help on using the changeset viewer.