摘要 |
The disclosed method for accessing a shared resource of a computerized system comprises a first thread running on the system, a first portion of said thread requesting a lock on the shared resource and directing the system to make the operations of a second thread visible in a correct order. The system then makes the operations of the second thread visible in a correct order. A second portion of the first thread is then run to determine whether the first thread has obtained the lock on the resource. The method may also store a lock request value in a memory variable which is accessible by both threads. Then perform a memory barrier operation which guarantees execution of the store operation before any other operation and as the next operation performing a system call which to make the operations of a second thread visible in a correct order. The method may also when performing the system call execute code to change protection of a page of memory of the system. The method may also have the second portion of the thread perform a load operation of a variable to determine whether the thread has obtained the lock on the resource. |