Changes between Version 2 and Version 3 of PTVS_Impl

Dec 27, 2009, 9:41:16 AM (14 years ago)



  • PTVS_Impl

    v2 v3  
    11[wiki:ParallelTrafficViewSimulator << Home]
    3 //TODO
     4Introduction of event processing threads ==
     6The question is now where the event processing threads should be introduced. [[BR]]
     8'''First idea'''[[BR]]
     10The first idea was to dynamically split the map into several independent regions. The events coming from independent regions should be introduced in different event queues. When we extract the event, the corresponding thread should to the processing. [[BR]]
     12This idea could not be applied because at certain moments GPS and Cleanup events are generated and we cannot put these events in different queues. This is not possible because for these events we cannot determine their location. [[BR]]
     13The event Send and Receive have a sender and a receiver and the sender or receiver has a location. The GPS and Cleanup events are not linked to a source or destination location. [[BR]]
     14The list with vehicles is iterated and for every vehicle we process the event. Furthermore the event queue should be managed by a master thread because the small different event queues would require too much synchronization.[[BR]]
     16'''Second idea'''[[BR]]
     18The second idea was to use only one event queue, but every event to have a reference to a different processing thread. When we add an event to the queue, we attach a processing thread, and when we extract the event for processing, we wake up the corresponding thread to do the actual processing.[[BR]]
     20This idea could work, but the next idea is simpler and does not require the change of implementation of the Event class to introduce the reference to a thread. [[BR]]
     22'''Third idea'''[[BR]]
     24In the method step() we extract an event from the queue (Event e = (Event) eventQueue.get(0);)[[BR]]
     26If the event is to be processed at the current time (if (e.getTime() == crtTime) ) we call playEvent() to actually process the event. [[BR]]
     28Only send and receive events have references to objects like sender and receiver and these objects provide the means to find the source or destination location of the event. [[BR]]
     30The idea is to find the type of event in the step method after getting the event from queue and then interrogating the type of event. For the events GPS and Cleanup we let the main thread to do the work. For the send and receive events we find the location (latitude and longitude). The field sender in the event provides the road index from the global array of roads. Then we have the information required to find all the points on the road and the point index provides the specific point, the location of the event.[[BR]]
     32The next step is to find the closest intersection to the event. Every intersection has a thread assigned to do the event processing. A future work requires a better load balancing for work processing and the creation of a proper number of threads, matching the architecture and the power of the physical processor. [[BR]]
     34We have a vector of threads and the index of the closest intersection becomes the index of the processing thread. The thread calls the playEvent() method like the main thread did before.