Download presentation
Presentation is loading. Please wait.
Published byJeffry Johnson Modified over 9 years ago
1
C++ Agents Implementation Chris Rouse CSS 497
2
Outline Finish Agent Implementation Involves changes to the following classes: Agents_base.h/.cpp Agent.h/.cpp Mprocess.h/.cpp Messages.h/.cpp Exchange_helper.h/.cpp Attempt to fix Eclipse IDE development problems for C++ version
3
Agents_base.h/.cpp Must add methods: CallAll() Instantiate bag of Agents to use Must allocate Agents for each thread Will send a command to all agents to execute Wait for response back ManageAll() Will need to update information between all agents Manages spawning, migrating, and killing of agents
4
Agents_base.h/.cpp cont. Difficulties: All must pull from a single bag, causing a possibility for race conditions This leads to the bag of agents being a critical section NormalWiki exampleRace Condition To remedy the problem, we need to make use of pthread_mutex_lock() to control when a thread can access this bag
5
Agents_base.h/.cpp Mutex locking will help prevent race conditions by ‘locking down’ the critical section upon use Any requests must first acquire the lock rights before they can access the agents If bag is already locked, other requests must wait until the lock releases and notifyAll is called before attempting to gain the lock again
6
Agents_base.h/.cpp Difficulties cont: Waiting and Notifying Should wait to hear back about status of agent Typically we make use of Notify and Wait Can use provided methods barrierThreads and resumeThreads to wait and notify What to do when an Agent doesn’t send notifications back? At this time, we will assume that all Agents will respond and not take precautions in the event they do not As currently planned, if an Agent doesn’t respond, the program will simply crash
7
Agents_base.h/.cpp CallAll method will essentially work like so: Step 1: Create Bag of Agents Step 2: Lock Bag Upon First Pop Request Step 3: Remove Last Agent From Vector of Agents Step 4: Send Copy of Command to Popped Agent Step 5: Release the Lock Step 6: Continue Until Out of Agents Step 7: Wait for Agents to Finish Task Step 8: Collect Finished Agents into New Bag and Replace Old Bag
8
Agents.h/.cpp Must add methods: Spawn() To create Agents in current place Migrate() To move agents between Place locations Kill() To remove an Agent when it is finished with execution This must also handle sending the commands to the slave agents
9
Messages.h/.cpp & Exchange_helper.h/.cpp Messages will need to be modified: This will need to use the CallAll() & ManageAll() calls mentioned earlier Exchange_helper will need to be modified too Will need to be able to exchange agents between slaves This will happen either locally in the same place or through a set of slave locations
10
Current Status Still working on CallAll() method Reading and understanding existing code has been time consuming and confusing Working on recompilation of existing code using Makefile while on campus Decided to use a single bag of Agents to more efficiently handle race condition vs. Multiple bags of Agents Working on implementing tests to make sure Agents are being taken correctly and passed correct instructions Wait and Notify have not been used and tested yet
11
Current Difficulties Unfamiliar code Code is complex and often contains information that I don’t understand No working IDE Eclipse has issues with some of the function calls and classes Currently working on fixing problems that would prevent IDE development of the C++ version Unknown behavior Haven’t worked with the code’s output much yet, so any output I read needs to be checked for correct behavior, then rechecked with new changes Code must be recompiled on campus Code uses libraries stored in Professor Fukuda’s campus drive, so to recompile easily, needs to happen via SSH or on campus computers
12
Deprecation Fixes Some functions in the code are now deprecated and throw errors when used Most recent example is bcopy(), which is now deprecated in newer Linux systems My original fix was to include the String.h class, which had many of the deprecated values still included in it This call can now be made using the memcpy() call, which takes the same parameters as bcopy, and functions the same My current copy of the code contains all changes made for bcopy using a quick Linux ‘find | xargs | sed’ command to make all the necessary replacements, though no testing as of yet
13
Future Plans Finish wait/notify in Agents_base and check for errors Test the memcpy command to make sure it works as intended Fully test CallAll implementation Move onto Spawn and Kill methods of Agents when complete with all the above Continue to work on Eclipse IDE problems to enable further development easier for new research students
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.