samples/hung_task/hung_task_tests.c
Source file repositories/reference/linux-study-clean/samples/hung_task/hung_task_tests.c
File Facts
- System
- Linux kernel
- Corpus path
samples/hung_task/hung_task_tests.c- Extension
.c- Size
- 5151 bytes
- Lines
- 165
- Domain
- Support Tooling And Documentation
- Bucket
- samples
- Inferred role
- Support Tooling And Documentation: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/delay.hlinux/fs.hlinux/module.hlinux/mutex.hlinux/semaphore.hlinux/rwsem.h
Detected Declarations
function read_dummy_mutexfunction read_dummy_semaphorefunction read_dummy_rwsem_readfunction read_dummy_rwsem_writefunction hung_task_tests_initfunction hung_task_tests_exitmodule init hung_task_tests_init
Annotated Snippet
static const struct file_operations hung_task_mutex_fops = {
.read = read_dummy_mutex,
};
/* File operations for semaphore */
static const struct file_operations hung_task_sem_fops = {
.read = read_dummy_semaphore,
};
/* File operations for rw_semaphore read */
static const struct file_operations hung_task_rwsem_read_fops = {
.read = read_dummy_rwsem_read,
};
/* File operations for rw_semaphore write */
static const struct file_operations hung_task_rwsem_write_fops = {
.read = read_dummy_rwsem_write,
};
static int __init hung_task_tests_init(void)
{
hung_task_dir = debugfs_create_dir(HUNG_TASK_DIR, NULL);
if (IS_ERR(hung_task_dir))
return PTR_ERR(hung_task_dir);
/* Create debugfs files for mutex and semaphore tests */
debugfs_create_file(HUNG_TASK_MUTEX_FILE, 0400, hung_task_dir, NULL,
&hung_task_mutex_fops);
debugfs_create_file(HUNG_TASK_SEM_FILE, 0400, hung_task_dir, NULL,
&hung_task_sem_fops);
debugfs_create_file(HUNG_TASK_RWSEM_READ_FILE, 0400, hung_task_dir, NULL,
&hung_task_rwsem_read_fops);
debugfs_create_file(HUNG_TASK_RWSEM_WRITE_FILE, 0400, hung_task_dir, NULL,
&hung_task_rwsem_write_fops);
return 0;
}
static void __exit hung_task_tests_exit(void)
{
debugfs_remove_recursive(hung_task_dir);
}
module_init(hung_task_tests_init);
module_exit(hung_task_tests_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Masami Hiramatsu <mhiramat@kernel.org>");
MODULE_AUTHOR("Zi Li <amaindex@outlook.com>");
MODULE_DESCRIPTION("Simple sleep under lock files for testing hung task");
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/delay.h`, `linux/fs.h`, `linux/module.h`, `linux/mutex.h`, `linux/semaphore.h`, `linux/rwsem.h`.
- Detected declarations: `function read_dummy_mutex`, `function read_dummy_semaphore`, `function read_dummy_rwsem_read`, `function read_dummy_rwsem_write`, `function hung_task_tests_init`, `function hung_task_tests_exit`, `module init hung_task_tests_init`.
- Atlas domain: Support Tooling And Documentation / samples.
- Implementation status: pattern 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.