do_smart_update(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… do_smart_update(9)

okay so real talk, this is a page from the Kernel API Manual (the do_smart_update one, yes bestie, section 9) and it's honestly kind of iconic β€” it's the optimized version of update_queue and it does exactly as much work as it needs to and not a single syscall more. main character energy fr fr πŸŽ€


✨ NAME ✨

do_smart_update β€” the optimized update_queue, slay πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

void do_smart_update (struct sem_array *sma , struct sembuf *sops , int
nsops , int otime , struct wake_q_head *wake_q );

like, look at that signature. gorgeous. no notes. ⭐


🌸 ARGUMENTS 🌸

  • sma β€” the semaphore array πŸ’– (the whole vibe of this function revolves around it)
  • sops β€” the operations that were actually performed ✨ (past tense, bestie, they already happened)
  • nsops β€” the number of operations 🫢 (count 'em)
  • otime β€” force setting otime πŸ‘‘ (yes, force β€” it's giving assertive)
  • wake_q β€” the lockless wake-queue head 🧚 (lockless!! we love a low-contention queen)

πŸ”₯ DESCRIPTION πŸ”₯

okay so here's the tea: do_smart_update does the required calls to update_queue and wakeup_zero, based on the actual changes that were performed on the semaphore array. like, it's smart about it β€” hence the name, iykyk 😌

⚠️ but listen β€” the function does not do the actual wake-up. not me being responsible for my own callbacks πŸ™ˆ the caller is responsible for calling wake_up_q. it is safe to perform this call after dropping all locks, though, which is genuinely such a relief. 🫢

🌈 SEE ALSO 🌈

Kernel file ./ipc/sem.c, plus the whole friend group:


πŸ’œ and that's the page!! this little icon lives over in ./ipc, dropping in October 2026 β€” mwah, periodt, no cap, go read update_queue(9) next if you're obsessed with me πŸŽ€βœ¨

πŸ“¦ where this page comes from