Changeset 7c5320c in mainline for kernel/generic/src


Ignore:
Timestamp:
2023-02-07T16:03:05Z (2 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1eaead4
Parents:
5110d0a
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-07 15:59:26)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-07 16:03:05)
Message:

Use the semaphore interface instead of waitq in some places

Since we already have an underused semaphore API in the kernel,
it would be worthwhile to use it in places where the baseline
semaphore semantics are needed. It makes the function of the
calls obvious even to people unfamiliar with the details of
waitq API.

Location:
kernel/generic/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/chardev.c

    r5110d0a r7c5320c  
    5252{
    5353        indev->name = name;
    54         waitq_initialize(&indev->wq);
     54        semaphore_initialize(&indev->wq, 0);
    5555        irq_spinlock_initialize(&indev->lock, "chardev.indev.lock");
    5656        indev->counter = 0;
     
    8181        /* Index modulo size of buffer */
    8282        indev->index = indev->index % INDEV_BUFLEN;
    83         waitq_wakeup(&indev->wq, WAKEUP_FIRST);
     83        semaphore_up(&indev->wq);
    8484        irq_spinlock_unlock(&indev->lock, true);
    8585}
     
    115115        }
    116116
    117         waitq_sleep(&indev->wq);
     117        semaphore_down(&indev->wq);
    118118        irq_spinlock_lock(&indev->lock, true);
    119119        char32_t ch = indev->buffer[(indev->index - indev->counter) %
  • kernel/generic/src/main/kinit.c

    r5110d0a r7c5320c  
    111111#ifdef CONFIG_SMP
    112112        if (config.cpu_count > 1) {
    113                 waitq_initialize(&ap_completion_wq);
     113                semaphore_initialize(&ap_completion_semaphore, 0);
    114114
    115115                /*
  • kernel/generic/src/main/main.c

    r5110d0a r7c5320c  
    383383        timeout_init();
    384384
    385         waitq_wakeup(&ap_completion_wq, WAKEUP_FIRST);
     385        semaphore_up(&ap_completion_semaphore);
    386386        scheduler();
    387387        /* not reached */
  • kernel/generic/src/smp/smp.c

    r5110d0a r7c5320c  
    3939#ifdef CONFIG_SMP
    4040
    41 waitq_t ap_completion_wq;
     41semaphore_t ap_completion_semaphore;
    4242
    4343#endif /* CONFIG_SMP */
Note: See TracChangeset for help on using the changeset viewer.