Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 14 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

PDF:

Feature

When Threads Share

Managing shared resources with mutual exclusion

Issue: 10.4 (May/June 2012)
Author: JC Cruz
Article Description: No description available.
Article Length (in bytes): 13,519
Starting Page Number: 50
RBD Number: 10408
Resource File(s):

Download Icon project10408.zip Updated: Wednesday, May 2, 2012 at 1:26 AM

Related Link(s): None
Known Limitations: None

Excerpt of article text...

Sometimes threads have to share resources when they do their tasks. So today, we look at the problems caused by shared resources. We then study the concept of mutual exclusion, and learn how it coordinates shared access. Later, we look at two Real Studio classes that provide mutual exclusion.

Threads and the Common Resource

There are many cases where threads have to use the same resource. Consider the scenario in Figure 1. Threads A and B are part of a PDF utility. Both are parsing a PDF file, compressing image data and removing unwanted metadata. Both report their progress to a common dialog view, which sports two progress bars.

Now, consider the scenario in Figure 2. In this one, threads A and B form part of a database server. Thread A monitors a network port and processes all data queries. Thread B indexes the record data at regular intervals. Both use a single database model as their common resource.

The problems of sharing

Naturally, when threads use the same resource, problems can arise, often due to threads being unaware of each other.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com