1 / 13

C++ Agents Implementation

C++ Agents Implementation. Chris Rouse CSS 497. 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

oistin
Télécharger la présentation

C++ Agents Implementation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 Normal Wiki example Race 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 mustfirst acquire the lockrights before they canaccess the agents • If bag is already locked,other requests mustwait until the lock releases and notifyAllis called before attempting to gain thelock 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 Notifyand 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 AgentFrom Vector of Agents Step 4:Send Copy of Commandto Popped Agent Step 7:Wait for Agentsto Finish Task Step 8:Collect Finished Agents into New Bag and Replace Old Bag Step 5:Release the Lock Step 6:Continue UntilOut of Agents

  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

More Related