include/drm/task_barrier.h
Source file repositories/reference/linux-study-clean/include/drm/task_barrier.h
File Facts
- System
- Linux kernel
- Corpus path
include/drm/task_barrier.h- Extension
.h- Size
- 3022 bytes
- Lines
- 108
- Domain
- Repository Root And Misc
- Bucket
- include
- Inferred role
- Repository Root And Misc: implementation source
- Status
- source implementation candidate
Why This File Exists
Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.
- Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/semaphore.hlinux/atomic.h
Detected Declarations
struct task_barrierfunction task_barrier_signal_turnstilefunction task_barrier_initfunction task_barrier_add_taskfunction task_barrier_rem_taskfunction task_barrier_enterfunction task_barrier_exitfunction task_barrier_full
Annotated Snippet
struct task_barrier {
unsigned int n;
atomic_t count;
struct semaphore enter_turnstile;
struct semaphore exit_turnstile;
};
static inline void task_barrier_signal_turnstile(struct semaphore *turnstile,
unsigned int n)
{
int i;
for (i = 0 ; i < n; i++)
up(turnstile);
}
static inline void task_barrier_init(struct task_barrier *tb)
{
tb->n = 0;
atomic_set(&tb->count, 0);
sema_init(&tb->enter_turnstile, 0);
sema_init(&tb->exit_turnstile, 0);
}
static inline void task_barrier_add_task(struct task_barrier *tb)
{
tb->n++;
}
static inline void task_barrier_rem_task(struct task_barrier *tb)
{
tb->n--;
}
/*
* Lines up all the threads BEFORE the critical point.
*
* When all thread passed this code the entry barrier is back to locked state.
*/
static inline void task_barrier_enter(struct task_barrier *tb)
{
if (atomic_inc_return(&tb->count) == tb->n)
task_barrier_signal_turnstile(&tb->enter_turnstile, tb->n);
down(&tb->enter_turnstile);
}
/*
* Lines up all the threads AFTER the critical point.
*
* This function is used to avoid any one thread running ahead if the barrier is
* used repeatedly .
*/
static inline void task_barrier_exit(struct task_barrier *tb)
{
if (atomic_dec_return(&tb->count) == 0)
task_barrier_signal_turnstile(&tb->exit_turnstile, tb->n);
down(&tb->exit_turnstile);
}
/* Convinieince function when nothing to be done in between entry and exit */
static inline void task_barrier_full(struct task_barrier *tb)
{
task_barrier_enter(tb);
task_barrier_exit(tb);
}
#endif
Annotation
- Immediate include surface: `linux/semaphore.h`, `linux/atomic.h`.
- Detected declarations: `struct task_barrier`, `function task_barrier_signal_turnstile`, `function task_barrier_init`, `function task_barrier_add_task`, `function task_barrier_rem_task`, `function task_barrier_enter`, `function task_barrier_exit`, `function task_barrier_full`.
- Atlas domain: Repository Root And Misc / include.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.