From: Idan Sofer Date: 2003-02-17T16:17:47+09:00 Subject: Re: Threads and database access ביום ראשון, 16 בפברואר 2003, 23:43, Matija Kejzar כתב: > Greetings. > > Most of the data is stored in a (mySQL) database that > I access using DBI. However, as disk seeks are a slow > thing, I'm thinking of using a separate thread for If SQL cross-compatibility is not an issue, Perhaps you should consider using "INSERT DELAYED", refer to the MySQL manual on this matter. > "...if some thread happens to make a call to the > operating system that takes a long time to complete, > all threads will hang until the interpreter gets > control back" Ruby threads are "green threads", that is, they are managed by the interepter itself(user-level threads) and not the OS(kernel-level threads) That is, the C code section of Ruby checks once in a while if a context switch is needed, however, this cannot be done while making a system call, so during that time a thread context switch cannot occur. nevertheless,syscalls are not supposed to take long time to complete, the exception is I/O(which might block) but as I understand internally ruby overcomes the matter in most cases using async I/O, or some other technique(someone correct me here), at least in my experience. Idan