multithreading - Ruby GIL of MRI 1.9 -


in understanding, here's how mri 1.9 gil works:

  1. interpreter spawns new thread calling corresponding underlying c function , ask acquire "gil".
  2. if "gil" free, happy. if not, new thread wait , invoke separate timer thread set "timeslice"
  3. when current executing thread hit boundaries such return or checking backward branches, interpreter checks timer decide if context switch should happen.

however, pointed article, can guarantee atomicity pure c implementing. being said, if parts of our thread contains ruby code, still in danger of race condition.

my question if thread needs acquire gil before executing, why c implementation methods guarantee atomicity?

thank in advance!

the gvl guarantees 1 thread can execute ruby code @ same time. of course different ruby threads can execute ruby code @ different times.

besides, majority of ruby implementations doesn't have gvl anyway.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -