Locking with multiple readers

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

tom9876543 wrote://reset count of readers
this.numReaders -= 1; //this thread had a read lock
this.numReaders += (2 << 30) //atomic - allow readers to continue
That's a prime example of a very small bug. Compile the code and see how many atoms your atomic code assembles to.
tom9876543
Member
Member
Posts: 170
Joined: Wed Jul 18, 2007 5:51 am

Post by tom9876543 »

Hello Candy

I did mention earlier that this code is only for working out the logic. I know that you need special assembly code for certain things that why I put the comment "//atomic".

The code will be modified... although I have no idea how to do inline assembly I'll work it out.....
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

tom9876543 wrote:Hello Candy

I did mention earlier that this code is only for working out the logic. I know that you need special assembly code for certain things that why I put the comment "//atomic".

The code will be modified... although I have no idea how to do inline assembly I'll work it out.....
As long as you know it's there... :)
Post Reply