|
Jim wrote: >Barbara, > >This type of locking has been used for a number of years for file >and record locking in a number of applications without any problems, >admittedly on PCs though. You're probably referring to programming on old MS-Windows systems, which use a "cooperative multitasking" model. That meant that for processes to multitask, processes had to regularly cede control to the operating system. (Of course, processes could always refuse to cooperate, which often led to unresponsive systems.) Your naive model of locking may well work in that environment, but is of course dangerous in the big leagues. For at least the past 30 years, robust operating systems have used "preemptive multitasking", where the system schedules machine cycles for each process or thread. When one thread is testing a flag, the system may very well rip control away and give it to another thread that sets the very same flag rendering that technique utterly useless as a synchronization method. (Even Windows NT uses preemptive MT these days!) In many cases, even single machine instructions cannot be guaranteed to be performed without the possibility of interruption! (That, of course, complicates the job of the operating system developers. But CPUs are normally designed with at least one instruction guaranteed to be atomic which can be used to implement semaphores.) As Barbara stated, when dealing with threads, always expect the worst. ANY potentially shared resource within the thread should be treated with respect and care must be taken to ensure proper synchronization. Cheers! Hans Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.