c++ - what happens if Interrupts occur after mutex lock has been acquired -
i have multi-threaded c/c++ program services read , write requests frequently. synchronization purposes, have used mutex locks , unlocks. read , write threads acquire lock before performing operations. happens if 1 thread acquires lock , before release locks, interrupt occurs ? thread resume execution or have handle manually ?
user-side locks, including mutexes not block interrupts. important, since mutex may used protect read file on disk, or protect reception of packets network, , such, result reliant on interrupt.
in essence, "nothing" happens if there interrupt. interrupts handled os, other time. there nothing program needs in case, takes few microseconds or milliseconds longer whatever programmed task if happens.
some kernel-side locks, such spinlocks indeed block interrupts (on processor core) ensure other processes/threads not scheduled during process. there restrictions on functions kernel can use under these circumstances - example, wouldn't possible call blocking function (such sleep, wait-for-event or file-read or file-write) during time, because would, potentially, cause kernel lock up.
Comments
Post a Comment