tools/testing/selftests/sync/sync_wait.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/sync/sync_wait.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/sync/sync_wait.c- Extension
.c- Size
- 3442 bytes
- Lines
- 92
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
sync.hsw_sync.hsynctest.h
Detected Declarations
function files
Annotated Snippet
#include "sync.h"
#include "sw_sync.h"
#include "synctest.h"
int test_fence_multi_timeline_wait(void)
{
int timelineA, timelineB, timelineC;
int fenceA, fenceB, fenceC, merged;
int valid, active, signaled, ret;
timelineA = sw_sync_timeline_create();
timelineB = sw_sync_timeline_create();
timelineC = sw_sync_timeline_create();
fenceA = sw_sync_fence_create(timelineA, "fenceA", 5);
fenceB = sw_sync_fence_create(timelineB, "fenceB", 5);
fenceC = sw_sync_fence_create(timelineC, "fenceC", 5);
merged = sync_merge("mergeFence", fenceB, fenceA);
merged = sync_merge("mergeFence", fenceC, merged);
valid = sw_sync_fence_is_valid(merged);
ASSERT(valid, "Failure merging fence from various timelines\n");
/* Confirm fence isn't signaled */
active = sync_fence_count_with_status(merged, FENCE_STATUS_ACTIVE);
ASSERT(active == 3, "Fence signaled too early!\n");
ret = sync_wait(merged, 0);
ASSERT(ret == 0,
"Failure waiting on fence until timeout\n");
ret = sw_sync_timeline_inc(timelineA, 5);
active = sync_fence_count_with_status(merged, FENCE_STATUS_ACTIVE);
signaled = sync_fence_count_with_status(merged, FENCE_STATUS_SIGNALED);
ASSERT(active == 2 && signaled == 1,
"Fence did not signal properly!\n");
ret = sw_sync_timeline_inc(timelineB, 5);
active = sync_fence_count_with_status(merged, FENCE_STATUS_ACTIVE);
signaled = sync_fence_count_with_status(merged, FENCE_STATUS_SIGNALED);
ASSERT(active == 1 && signaled == 2,
"Fence did not signal properly!\n");
ret = sw_sync_timeline_inc(timelineC, 5);
active = sync_fence_count_with_status(merged, FENCE_STATUS_ACTIVE);
signaled = sync_fence_count_with_status(merged, FENCE_STATUS_SIGNALED);
ASSERT(active == 0 && signaled == 3,
"Fence did not signal properly!\n");
/* confirm you can successfully wait */
ret = sync_wait(merged, 100);
ASSERT(ret > 0, "Failure waiting on signaled fence\n");
sw_sync_fence_destroy(merged);
sw_sync_fence_destroy(fenceC);
sw_sync_fence_destroy(fenceB);
sw_sync_fence_destroy(fenceA);
sw_sync_timeline_destroy(timelineC);
sw_sync_timeline_destroy(timelineB);
sw_sync_timeline_destroy(timelineA);
return 0;
}
Annotation
- Immediate include surface: `sync.h`, `sw_sync.h`, `synctest.h`.
- Detected declarations: `function files`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.