| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Mutex semaphores |
Hi Phil,
Replying to a message of Phil Crown to All:
PC> ULONG someFn()
PC> {
PC> request.MutexSem();
PC> ULONG rc = 0;
Note rc is a stack variable, not static.
PC> rc = something;
PC> str = somethingtoo; // this also needs protecting because str is
PC> // used in another function that is also
PC> // called by two or more threads.
PC> release.MutexSem();
PC> return rc; // A calling thread is pre-empted here before returning
PC> rc.
PC> // A second threads comes along and completes the
PC> // function before the first thread has finished,
PC> // thus causing rc to contain invalid data.
PC> // Is this possible?
PC> }
No, because they're using different copies of rc. It is possible though,
that str is changed, since the declaration of str isn't shown here, I
assume it's not an auto variable.
Thanks,
Mike
--- FleetStreet 1.17+
* Origin: Common Sense BBS - 510.713.7336 Newark, CA (1:215/705)SEEN-BY: 50/99 270/101 620/243 625/160 711/401 409 410 413 430 808 809 934 SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1 @PATH: 215/705 270/101 712/515 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.