Changeset 9f945464 in mainline
- Timestamp:
- 2025-04-09T16:36:30Z (5 days ago)
- Children:
- 3acb63b5
- Parents:
- 2c94501 (diff), 597fa24 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Wayne Thornton <wmthornton-dev@…> (2025-04-09 16:36:30)
- git-committer:
- GitHub <noreply@…> (2025-04-09 16:36:30)
- Location:
- kernel
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/synch/condvar.h
r2c94501 r9f945464 46 46 } condvar_t; 47 47 48 #define CONDVAR_INITIALIZER(name) (condvar_t) { \ 49 .wq = WAITQ_INITIALIZER((name).wq), \ 50 } 51 52 #define CONDVAR_INITIALIZE(name) \ 53 condvar_t name = CONDVAR_INITIALIZER(name) 54 48 55 #ifdef CONFIG_SMP 49 56 #define _condvar_wait_timeout_spinlock(cv, lock, usec, flags) \ -
kernel/generic/include/synch/mutex.h
r2c94501 r9f945464 56 56 } mutex_t; 57 57 58 #define MUTEX_INITIALIZER(name, mtype) (mutex_t) { \ 59 .type = (mtype), \ 60 .sem = SEMAPHORE_INITIALIZER((name).sem, 1), \ 61 .owner = NULL, \ 62 .nesting = 0, \ 63 } 64 65 #define MUTEX_INITIALIZE(name, mtype) \ 66 mutex_t name = MUTEX_INITIALIZER(name, mtype) 67 58 68 extern void mutex_initialize(mutex_t *, mutex_type_t); 59 69 extern bool mutex_locked(mutex_t *); -
kernel/generic/include/synch/semaphore.h
r2c94501 r9f945464 45 45 } semaphore_t; 46 46 47 #define SEMAPHORE_INITIALIZER(name, count) (semaphore_t) { \ 48 .wq = WAITQ_INITIALIZER_WITH_COUNT((name).wq, count), \ 49 } 50 51 #define SEMAPHORE_INITIALIZE(name, count) \ 52 semaphore_t name = SEMAPHORE_INITIALIZER(name, count) 53 47 54 extern void semaphore_initialize(semaphore_t *, int); 48 55 extern errno_t semaphore_down_timeout(semaphore_t *, uint32_t); -
kernel/generic/include/synch/waitq.h
r2c94501 r9f945464 40 40 #include <abi/synch.h> 41 41 #include <adt/list.h> 42 43 #define WAITQ_INITIALIZER_WITH_COUNT(name, count) (waitq_t) { \ 44 .lock = IRQ_SPINLOCK_INITIALIZER(#name ".lock"), \ 45 .sleepers = LIST_INITIALIZER((name).sleepers), \ 46 .wakeup_balance = (count), \ 47 } 48 49 #define WAITQ_INITIALIZER(name) WAITQ_INITIALIZER_WITH_COUNT(name, 0) 50 51 #define WAITQ_INITIALIZE_WITH_COUNT(name, count) \ 52 waitq_t name = WAITQ_INITIALIZER_WITH_COUNT(name, count) 53 54 #define WAITQ_INITIALIZE(name) \ 55 waitq_t name = WAITQ_INITIALIZER(name) 42 56 43 57 /** Wait queue structure. -
kernel/generic/src/ddi/ddi.c
r2c94501 r9f945464 60 60 61 61 /** This lock protects the @c pareas ordered dictionary. */ 62 static mutex_t pareas_lock;62 static MUTEX_INITIALIZE(pareas_lock, MUTEX_PASSIVE); 63 63 64 64 /** Ordered dictionary of enabled physical memory areas by base address. */ … … 74 74 { 75 75 odict_initialize(&pareas, pareas_getkey, pareas_cmp); 76 mutex_initialize(&pareas_lock, MUTEX_PASSIVE);77 76 } 78 77 -
kernel/generic/src/main/main.c
r2c94501 r9f945464 53 53 #include <stdio.h> 54 54 #include <panic.h> 55 #include <assert.h>56 55 #include <config.h> 57 56 #include <time/clock.h> -
kernel/generic/src/mm/frame.c
r2c94501 r9f945464 63 63 #include <proc/thread.h> /* THREAD */ 64 64 65 zones_t zones; 65 zones_t zones = { 66 .count = 0, 67 .lock = IRQ_SPINLOCK_INITIALIZER("frame.zones.lock"), 68 }; 66 69 67 70 /* … … 69 72 * available. 70 73 */ 71 static mutex_t mem_avail_mtx;72 static condvar_t mem_avail_cv;74 static MUTEX_INITIALIZE(mem_avail_mtx, MUTEX_ACTIVE); 75 static CONDVAR_INITIALIZE(mem_avail_cv); 73 76 static size_t mem_avail_req = 0; /**< Number of frames requested. */ 74 77 static size_t mem_avail_gen = 0; /**< Generation counter. */ … … 1108 1111 void frame_init(void) 1109 1112 { 1110 if (config.cpu_active == 1) {1111 zones.count = 0;1112 irq_spinlock_initialize(&zones.lock, "frame.zones.lock");1113 mutex_initialize(&mem_avail_mtx, MUTEX_ACTIVE);1114 condvar_initialize(&mem_avail_cv);1115 }1116 1117 1113 /* Tell the architecture to create some memory */ 1118 1114 frame_low_arch_init(); -
kernel/generic/src/proc/thread.c
r2c94501 r9f945464 667 667 void thread_usleep(uint32_t usec) 668 668 { 669 waitq_t wq; 670 671 waitq_initialize(&wq); 672 669 WAITQ_INITIALIZE(wq); 673 670 (void) waitq_sleep_timeout(&wq, usec); 674 671 } -
kernel/generic/src/synch/condvar.c
r2c94501 r9f945464 48 48 void condvar_initialize(condvar_t *cv) 49 49 { 50 waitq_initialize(&cv->wq);50 *cv = CONDVAR_INITIALIZER(*cv); 51 51 } 52 52 -
kernel/generic/src/synch/mutex.c
r2c94501 r9f945464 53 53 void mutex_initialize(mutex_t *mtx, mutex_type_t type) 54 54 { 55 mtx->type = type; 56 mtx->owner = NULL; 57 mtx->nesting = 0; 58 semaphore_initialize(&mtx->sem, 1); 55 *mtx = MUTEX_INITIALIZER(*mtx, type); 59 56 } 60 57 -
kernel/generic/src/synch/semaphore.c
r2c94501 r9f945464 52 52 void semaphore_initialize(semaphore_t *sem, int val) 53 53 { 54 waitq_initialize_with_count(&sem->wq, val);54 *sem = SEMAPHORE_INITIALIZER(*sem, val); 55 55 } 56 56 -
kernel/generic/src/synch/waitq.c
r2c94501 r9f945464 70 70 void waitq_initialize(waitq_t *wq) 71 71 { 72 memsetb(wq, sizeof(*wq), 0); 73 irq_spinlock_initialize(&wq->lock, "wq.lock"); 74 list_initialize(&wq->sleepers); 72 *wq = WAITQ_INITIALIZER(*wq); 75 73 } 76 74 … … 81 79 void waitq_initialize_with_count(waitq_t *wq, int count) 82 80 { 83 waitq_initialize(wq); 84 wq->wakeup_balance = count; 81 *wq = WAITQ_INITIALIZER_WITH_COUNT(*wq, count); 85 82 } 86 83 -
kernel/generic/src/sysinfo/stats.c
r2c94501 r9f945464 90 90 91 91 /** Load calculation lock */ 92 static mutex_t load_lock;92 static MUTEX_INITIALIZE(load_lock, MUTEX_PASSIVE); 93 93 94 94 /** Get statistics of all CPUs … … 846 846 void stats_init(void) 847 847 { 848 mutex_initialize(&load_lock, MUTEX_PASSIVE);849 850 848 sysinfo_set_item_gen_data("system.cpus", NULL, get_stats_cpus, NULL); 851 849 sysinfo_set_item_gen_data("system.physmem", NULL, get_stats_physmem, NULL); -
kernel/generic/src/sysinfo/sysinfo.c
r2c94501 r9f945464 57 57 58 58 /** Sysinfo lock */ 59 static mutex_t sysinfo_lock;59 static MUTEX_INITIALIZE(sysinfo_lock, MUTEX_ACTIVE); 60 60 61 61 /** Sysinfo item constructor … … 102 102 sizeof(sysinfo_item_t), 0, sysinfo_item_constructor, 103 103 sysinfo_item_destructor, SLAB_CACHE_MAGDEFERRED); 104 105 mutex_initialize(&sysinfo_lock, MUTEX_ACTIVE);106 104 } 107 105 -
kernel/test/mm/slab2.c
r2c94501 r9f945464 127 127 128 128 static slab_cache_t *thr_cache; 129 static condvar_t thread_starter;130 static mutex_t starter_mutex;129 static CONDVAR_INITIALIZE(thread_starter); 130 static MUTEX_INITIALIZE(starter_mutex, MUTEX_PASSIVE); 131 131 132 132 #define THREADS 8 … … 197 197 198 198 TPRINTF("Running stress test with size %d\n", size); 199 200 condvar_initialize(&thread_starter);201 mutex_initialize(&starter_mutex, MUTEX_PASSIVE);202 199 203 200 thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0);
Note:
See TracChangeset
for help on using the changeset viewer.