[{"id":"linuxadvanced-001","courseId":"linux-advanced","domain":"processes-and-scheduling","topic":"pidfd_open process handles","prompt":"A parent forks a child and sets SIGCHLD to SIG_IGN. Later, after the child may have exited, the parent wants a PID file descriptor for it that cannot end up naming a recycled PID. What should it use?","hint":"Think about what keeps an exited child's PID from being reused.","explain":"A PID can be reused once its process is fully gone, so a PID-based handle is only safe while the exited child stays a zombie. How the parent handles SIGCHLD and reaping decides that.","source":"https://man7.org/linux/man-pages/man2/pidfd_open.2.html","interaction":{"type":"single"},"options":[{"id":"a","text":"clone(2) with the CLONE_PIDFD flag","why":"When the zombie guarantee does not hold, the page says to create the child with clone(2) and CLONE_PIDFD, which returns the handle along with the child."},{"id":"b","text":"pidfd_open() called right after fork()","whyNot":"pidfd_open() is only guaranteed to name the exited child if SIGCHLD is not set to SIG_IGN, so here it is not safe."},{"id":"c","text":"Opening /proc/<pid> as a directory","whyNot":"That works only if proc is mounted, and the descriptor is not pollable and can't be waited on with waitid(2)."},{"id":"d","text":"sigaction() with SA_NOCLDWAIT, then pidfd_open()","whyNot":"SA_NOCLDWAIT breaks one of the conditions the guarantee depends on, so it does not make pidfd_open() safe."}],"answer":"a","explanation":"pidfd_open() can name an exited child only while SIGCHLD is not ignored, SA_NOCLDWAIT is unset and the zombie is unreaped; otherwise use clone(2) with CLONE_PIDFD.","concept":"pidfd_open() can name an exited child only while SIGCHLD is not ignored, SA_NOCLDWAIT is unset and the zombie is unreaped; otherwise use clone(2) with CLONE_PIDFD.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Create the child with clone(2) and CLONE_PIDFD when SIGCHLD is ignored or the zombie may be reaped elsewhere."]},{"id":"linuxadvanced-002","courseId":"linux-advanced","domain":"processes-and-scheduling","topic":"io_uring rings","prompt":"On Linux 5.5 or later, you set up an io_uring instance and read the features field the kernel fills in. Your completion queue fills up while you keep submitting. Which feature flag tells you the kernel keeps extra completions instead of dropping them?","hint":"Look at the feature flags the kernel reports, not the setup flags.","explain":"Completions are posted into a fixed-size ring that the application reads. The kernel reports supported behavior back in a features field, so check it rather than assume a default.","source":"https://man7.org/linux/man-pages/man2/io_uring_setup.2.html","interaction":{"type":"single"},"options":[{"id":"a","text":"IORING_FEAT_NODROP","why":"If the CQ ring is full, the kernel stores the completion internally until there is room, so events are almost never dropped."},{"id":"b","text":"IORING_FEAT_SUBMIT_STABLE","whyNot":"It guarantees that async data has been consumed once the kernel consumes the SQE; that is about buffer lifetime, not a full CQ ring."},{"id":"c","text":"IORING_FEAT_RW_CUR_POS","whyNot":"It lets an offset of -1 mean the current file position for read and write operations."},{"id":"d","text":"IORING_FEAT_SINGLE_MMAP","whyNot":"It lets the SQ and CQ rings be mapped with a single mmap(2) call; it only reduces the number of mmap calls."}],"answer":"a","explanation":"IORING_FEAT_NODROP reports that when the CQ ring is full, the kernel stores completion events internally instead of dropping them.","concept":"IORING_FEAT_NODROP reports that when the CQ ring is full, the kernel stores completion events internally instead of dropping them.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Read the features field after io_uring_setup(2) before relying on how the kernel handles completions."]},{"id":"linuxadvanced-003","courseId":"linux-advanced","domain":"processes-and-scheduling","topic":"EEVDF task selection","prompt":"With EEVDF as the Linux fair scheduler, the kernel considers only tasks whose lag is zero or positive, then runs the one with the earliest virtual deadline.","hint":"Think about which tasks are still owed CPU time.","explain":"EEVDF gives each task a lag value showing whether it is owed CPU time or has used more than its share. Among tasks that qualify, the earliest virtual deadline decides who runs next.","source":"https://docs.kernel.org/scheduler/sched-eevdf.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","why":"EEVDF picks tasks with lag greater than or equal to zero, then selects the one with the earliest virtual deadline."},{"id":"b","text":"False","whyNot":"EEVDF picks tasks with lag greater than or equal to zero, so the statement is accurate as written."}],"answer":"a","explanation":"EEVDF picks only tasks with lag of zero or more, then runs the one with the earliest virtual deadline.","concept":"EEVDF picks only tasks with lag of zero or more, then runs the one with the earliest virtual deadline.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Lag decides which tasks are eligible; virtual deadlines choose among the eligible ones."]},{"id":"linuxadvanced-004","courseId":"linux-advanced","domain":"processes-and-scheduling","topic":"Thread-directed signals","prompt":"A process has threads A, B, C and D. Thread A blocks SIGUSR1, while B, C and D leave it unblocked. Thread A then calls kill(getpid(), SIGUSR1) to signal the whole process. Which thread takes the signal?","hint":"Ask whether the signal is aimed at one thread or at the process as a whole.","explain":"Each thread has its own signal mask listing the signals it currently blocks. Signals are either aimed at one thread or at the process as a whole.","source":"https://man7.org/linux/man-pages/man7/signal.7.html","interaction":{"type":"single"},"options":[{"id":"a","text":"One of B, C or D, chosen arbitrarily by the kernel","why":"A process-directed signal goes to any thread that has it unblocked, and the kernel chooses one of those arbitrarily."},{"id":"b","text":"Thread A, because it sent the signal","whyNot":"Thread A blocks SIGUSR1, so it is not among the threads that can receive the signal."},{"id":"c","text":"The main thread, which is always preferred","whyNot":"The kernel chooses an arbitrary unblocked thread, so no thread, including the main one, is always preferred."},{"id":"d","text":"All of B, C and D, each getting its own copy","whyNot":"A process-directed signal is pending for the process as a whole, and only one unblocked thread takes it."}],"answer":"a","explanation":"A process-directed signal is delivered to one thread that does not block it, and the kernel picks that thread arbitrarily.","concept":"A process-directed signal is delivered to one thread that does not block it, and the kernel picks that thread arbitrarily.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Use tgkill(2) or pthread_kill(3) when a specific thread must receive the signal."]},{"id":"linuxadvanced-005","courseId":"linux-advanced","domain":"processes-and-scheduling","topic":"SCHED_DEADLINE","prompt":"A team gives a real-time thread the SCHED_DEADLINE policy with a runtime, a deadline and a period. Which TWO statements about how Linux handles this policy are correct?","hint":"Think about the order the three timing values must follow, and what the kernel checks at setup.","explain":"SCHED_DEADLINE reserves CPU time for a task, described by a runtime, a relative deadline and a period. The kernel checks whether the reservations it accepts can still all be met before it grants one.","source":"https://man7.org/linux/man-pages/man7/sched.7.html","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"The kernel requires runtime <= deadline <= period for the three parameters.","why":"The page states that sched_runtime <= sched_deadline <= sched_period is required."},{"id":"b","text":"sched_setattr(2) fails with EBUSY when the admission test finds the set infeasible.","why":"The admission test refuses a change that would make the deadline threads unschedulable, and it fails with EBUSY."},{"id":"c","text":"Set the policy with sched_setscheduler(2) and static priority 0.","whyNot":"The page says the policy and its attributes are set with the Linux-specific sched_setattr(2) and read with sched_getattr(2)."},{"id":"d","text":"Deadline threads are lower priority than SCHED_OTHER threads, so normal threads run first.","whyNot":"They are the highest-priority user-controllable threads, and a runnable one preempts SCHED_OTHER threads."},{"id":"e","text":"A fork(2) by a deadline thread always succeeds, and the child keeps the deadline policy.","whyNot":"Such a fork fails with EAGAIN unless the reset-on-fork flag is set."},{"id":"f","text":"A deadline thread calling sched_yield(2) goes to the back of its priority list, as with SCHED_RR.","whyNot":"It yields the current job and waits for a new period to begin, which is different from round-robin rotation."}],"answer":"ab","explanation":"SCHED_DEADLINE needs runtime <= deadline <= period, and sched_setattr(2) fails with EBUSY when the admission test finds the set infeasible.","concept":"SCHED_DEADLINE needs runtime <= deadline <= period, and sched_setattr(2) fails with EBUSY when the admission test finds the set infeasible.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Deadline reservations are admitted or refused at setup, so a set that cannot be met fails with EBUSY."]}]