Go to Post please....Mr. Needel is my father :rolleyes: - Greg Needel [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 14 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 11-02-2010, 15:55
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Task Creation and Semaphore Tutorial

Unless you have fancy code, you should not encounter this (for the most part), but watch out for race conditions and locking.
if I have task A and it is running:
Code:
CRITICAL_REGION(Sem1)
Wait(5.0);//demo purposes
CRITICAL_REGION(Sem2)
/*Code here*/
END_REGION
END_REGION
and you have Task B running:
Code:
CRITICAL_REGION(Sem2)
Wait(5.0);//demo purposes
CRITICAL_REGION(Sem1)
/*Code here*/
END_REGION
END_REGION
Assuming they were started within 5 seconds of each other, they will both lock, and nothing will happen. Why?
Task A locks Sem1 and waits for 5 seconds, where Task B starts, and Locks Sem2
Task A has waited 5 seconds, and tries to lock Sem2, but Task B has it, so It waits for B to release it.
Meanwhile, B has waited its 5 seconds, and tries to Lock Sem1, but Task A has it so it waits for A to release it.
they are each waiting for the other to do something, so they do nothing
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
printf not working and UserProgram_StartupLibraryInit task deleted John Young C/C++ 4 08-02-2010 21:36
semaphore of the trailer frcchile Technical Discussion 3 26-01-2009 13:56
New LabVIEW TipJar Tutorial Video: Scalability, Modularity and Style. LVMastery NI LabVIEW 0 18-01-2009 14:56
Question about 3rd Tutorial ETA and FRC Modeler Motor Config Ted155 LabView and Data Acquisition 2 21-01-2007 19:45


All times are GMT -5. The time now is 15:20.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi