Question: Juspay Hackathon round B
4
Entering edit mode

Tree Of Space Question extended part

Let's say you are running the lock/unlock in a multi-core machine. Now you want to let multiple threads run lock() simultaneously. As we saw in part I, locking a node has multiple validations inside. While doing lock on two nodes causes a race condition. If yes, how will you solve it? In short, how do make the lock() function thread safe?

  • Multiple threads running it simultaneously shouldn't not affect the correctness.
  • Try to make the critical sections more granular. ie. don't create any big atomic/synchronized blocks that will make parallelism suffer
ADD COMMENTlink 16 months ago Ankit • 60
0
Entering edit mode

Did you get the solution for this?

ADD COMMENTlink 11 months ago Akshata chavan • 0

Login before adding your answer.

Similar Posts
Loading Similar Posts