

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























Introducing some principles of reentrancy, mutual exclusion and thread-synchronization
struct file_operations my_fops =
{ owner: THIS_MODULE, read: my_read, write: my_write, open: my_open, release: my_release, };
count sleepers lock task_list
For a mutual-exclusion semaphore (i.e., a ‘mutex’), the ‘count’ field will be initialized to 1, meaning that at most one task is allowed to acquire the semaphore at any given moment A task ‘aquires the semaphore’ when it calls the ‘ down ( &sem )’ function That function decrements the ‘count’ value, then immediately returns if the new value of ‘count’ is non-negative; otherwise, the task is ‘put to sleep’ on the semaphore’s ‘task_list’ wait-queue (and ‘sleepers’ is incremented); later, when another task that had acquired the semaphore calls the ‘ up ( &sem )’ function, the value of ‘count’ will get incremented and any tasks sleeping on this wait_queue will be awakened
prev next
sem