Changeset 455241b in mainline for kernel/generic/src/synch/syswaitq.c


Ignore:
Timestamp:
2025-01-16T19:29:20Z (13 days ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
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)
Message:

Integrate kobject_t into target structures

This just means fewer allocations and indirections.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/syswaitq.c

    rdf721df r455241b  
    4848static slab_cache_t *waitq_cache;
    4949
    50 static void waitq_destroy(void *arg)
     50typedef struct {
     51        kobject_t kobject;
     52        waitq_t waitq;
     53} waitq_kobject_t;
     54
     55static void waitq_destroy(kobject_t *arg)
    5156{
    52         waitq_t *wq = (waitq_t *) arg;
     57        waitq_kobject_t *wq = (waitq_kobject_t *) arg;
    5358        slab_free(waitq_cache, wq);
    5459}
    5560
    5661kobject_ops_t waitq_kobject_ops = {
    57         .destroy = waitq_destroy
     62        .destroy = waitq_destroy,
    5863};
    5964
     
    6166void sys_waitq_init(void)
    6267{
    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);
    6570}
    6671
     
    7479sys_errno_t sys_waitq_create(uspace_ptr_cap_waitq_handle_t whandle)
    7580{
    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)
    7883                return (sys_errno_t) ENOMEM;
    79         waitq_initialize(wq);
    8084
    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);
    8787
    8888        cap_handle_t handle;
    8989        errno_t rc = cap_alloc(TASK, &handle);
    9090        if (rc != EOK) {
    91                 slab_free(waitq_cache, wq);
    92                 kobject_free(kobj);
     91                slab_free(waitq_cache, kobj);
    9392                return (sys_errno_t) rc;
    9493        }
     
    9796        if (rc != EOK) {
    9897                cap_free(TASK, handle);
    99                 kobject_free(kobj);
    100                 slab_free(waitq_cache, wq);
     98                slab_free(waitq_cache, kobj);
    10199                return (sys_errno_t) rc;
    102100        }
    103101
    104         cap_publish(TASK, handle, kobj);
     102        cap_publish(TASK, handle, &kobj->kobject);
    105103
    106104        return (sys_errno_t) EOK;
     
    135133    unsigned int flags)
    136134{
    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);
    138137        if (!kobj)
    139138                return (sys_errno_t) ENOENT;
     
    143142#endif
    144143
    145         errno_t rc = _waitq_sleep_timeout(kobj->waitq, timeout,
     144        errno_t rc = _waitq_sleep_timeout(&kobj->waitq, timeout,
    146145            SYNCH_FLAGS_INTERRUPTIBLE | flags);
    147146
     
    150149#endif
    151150
    152         kobject_put(kobj);
     151        kobject_put(&kobj->kobject);
    153152
    154153        return (sys_errno_t) rc;
     
    163162sys_errno_t sys_waitq_wakeup(cap_waitq_handle_t whandle)
    164163{
    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);
    166166        if (!kobj)
    167167                return (sys_errno_t) ENOENT;
    168168
    169         waitq_wake_one(kobj->waitq);
     169        waitq_wake_one(&kobj->waitq);
    170170
    171         kobject_put(kobj);
     171        kobject_put(&kobj->kobject);
    172172        return (sys_errno_t) EOK;
    173173}
Note: See TracChangeset for help on using the changeset viewer.