001 package cnslab.cnsnetwork; 002 003 import java.io.*; 004 import java.util.*; 005 import java.util.concurrent.*; 006 import org.w3c.dom.*; 007 import org.w3c.dom.ls.*; 008 import org.w3c.dom.bootstrap.*; 009 010 import jpvm.*; 011 import org.slf4j.Logger; 012 import org.slf4j.LoggerFactory; 013 014 import cnslab.cnsmath.*; 015 import edu.jhu.mb.ernst.net.PeerInfo; 016 017 /*********************************************************************** 018 * NetHost class. 019 * 020 * It first initialize itself, prepare the jpvm environment. 021 * populate the neurons, build up the network structure, 022 * start the executing thread, then listen to message from trial host 023 * and mainhost. 024 * 025 * @version 026 * $Date: 2012-08-04 13:43:22 -0500 (Sat, 04 Aug 2012) $ 027 * $Rev: 104 $ 028 * $Author: croft $ 029 * @author 030 * Yi Dong 031 * @author 032 * David Wallace Croft 033 ***********************************************************************/ 034 public class NetHost 035 //////////////////////////////////////////////////////////////////////// 036 //////////////////////////////////////////////////////////////////////// 037 { 038 039 private static final Class<NetHost> 040 CLASS = NetHost.class; 041 042// private static final String 043// CLASS_NAME = CLASS.getName ( ); 044 045 private static final Logger 046 LOGGER = LoggerFactory.getLogger ( CLASS ); 047 048 //public static JpvmInfo info; 049 050 //////////////////////////////////////////////////////////////////////// 051 //////////////////////////////////////////////////////////////////////// 052 053 public static void main ( final String [ ] args ) 054 //////////////////////////////////////////////////////////////////////// 055 { 056 jpvmEnvironment jpvmEnvironmentInstance = null; 057 058 try 059 { 060 // double minDelay; 061 062 // double backFire; 063 064 // Enroll in the parallel virtual machine... 065 066 jpvmEnvironmentInstance = new jpvmEnvironment ( ); 067 068 // receive information about its peers 069 070 // It will hang here until it receives a network message. 071 072 final jpvmMessage message 073 = jpvmEnvironmentInstance.pvm_recv ( NetMessageTag.sendTids ); 074 075 final PeerInfo peerInfo = new PeerInfo ( message ); 076 077 launch ( jpvmEnvironmentInstance, peerInfo ); 078 079 jpvmEnvironmentInstance.pvm_exit ( ); 080 } 081 catch (jpvmException jpe) 082 { 083 System.out.println("Error - jpvm exception"); 084 085 try 086 { 087 if ( jpvmEnvironmentInstance != null ) 088 { 089 FileOutputStream out = new FileOutputStream( 090 "log/"+jpvmEnvironmentInstance.pvm_mytid().getHost() 091 +"error.txt"); 092 093 PrintStream p = new PrintStream(out); 094 095 jpe.printStackTrace(p); 096 097 p.close(); 098 } 099 } 100 catch(Exception ex) 101 { 102 // 103 } 104 } 105 catch (Exception a) 106 { 107 try 108 { 109 if ( jpvmEnvironmentInstance != null ) 110 { 111 FileOutputStream out = new FileOutputStream( 112 "log/"+ jpvmEnvironmentInstance.pvm_mytid().getHost() 113 +"error.txt"); 114 115 PrintStream p = new PrintStream(out); 116 117 a.printStackTrace(p); 118 119 p.close(); 120 } 121 } 122 catch(Exception ex) 123 { 124 // 125 } 126 } 127 } 128 129 public static void launch ( 130 final jpvmEnvironment jpvmEnvironmentInstance, 131 final PeerInfo peerInfo ) 132 throws Exception, jpvmException 133 //////////////////////////////////////////////////////////////////////// 134 { 135 final JpvmInfo jpvmInfo = new JpvmInfo ( ); 136 137 jpvmInfo.jpvm = jpvmEnvironmentInstance; 138 139 jpvmInfo.myJpvmTaskId = jpvmEnvironmentInstance.pvm_mytid ( ); 140 141 // Get my parent's task id... 142 // info.parent = info.jpvm.pvm_parent(); 143 // actually it is grand parent; 144 145 peerInfo.populateJpvmInfo ( jpvmInfo ); 146 147 int seedInt = peerInfo.seedInt; 148 149 // NetHosts tid 150 151 //FileOutputStream outt = new FileOutputStream( 152 // "log/"+info.parent.getHost()+"_preinfo"+iter_int+".txt"); 153 //PrintStream p = new PrintStream(outt); 154 155 // String out="Host id "+info.idIndex+"\n"; 156 157 final DOMImplementationRegistry 158 registry = DOMImplementationRegistry.newInstance ( ); 159 160 final DOMImplementationLS impl 161 = ( DOMImplementationLS ) registry.getDOMImplementation ( "LS" ); 162 163 final SimulatorParser simulatorParser = createSimulatorParser ( 164 impl, 165 peerInfo.byteArray, 166 seedInt, 167 jpvmInfo ); 168 169 final CyclicBarrier barrier = new CyclicBarrier ( 2 ); 170 171 /* 172 //receiving neurons 173 m = info.jpvm.pvm_recv(NetMessageTag.sendNeurons); 174 int numNeurons; 175 numNeurons = m.buffer.upkint(); 176 int base = m.buffer.upkint(); 177 // the last neuron is a sync neuron 178 Neuron neurons[] = new Neuron[numNeurons+1]; 179 m.buffer.unpack(neurons,numNeurons,1); 180 */ 181 182 /* 183 out=out+"\n"; 184 for(int i=0; i< numNeurons; i++) 185 { 186 out=out+"Neurons are:"+neurons[i].toString(); 187 } 188 */ 189 190 final Seed idum = new Seed ( seedInt - jpvmInfo.idIndex ); 191 192 // neurons, pvminfo, base index, mini delay, background freq, 193 // seed number 194 195 final Network testNet = new Network ( 196 simulatorParser.getModelFactory ( ), 197 simulatorParser.getDiscreteEventQueue ( ), 198 simulatorParser.getModulatedSynapseSeq ( ), 199 simulatorParser.layerStructure.neurons, 200 simulatorParser.layerStructure.axons, 201 jpvmInfo, 202 simulatorParser.layerStructure.base, 203 simulatorParser.minDelay, 204 simulatorParser, 205 idum, 206 simulatorParser.experiment ); 207 208 testNet.initNet ( ); 209 210 // pas.p = testNet.p; 211 212 213 // if(info.idIndex==0) pas.ls.connectFrom("O,0,0,E", testNet.p); 214 // if(info.idIndex==4) pas.ls.connectFrom("O,0,16,0,E", testNet.p); 215 // pas.ls.connectFrom("T,27,9,L", testNet.p); 216 217 testNet.p.println("Host id "+jpvmInfo.idIndex+"\n"); 218 219 testNet.p.println("base "+testNet.base+"\n"); 220 221 testNet.p.println("idum "+idum.seed+"\n"); 222 223 testNet.p.println("NumOfSyn "+simulatorParser.layerStructure.numSYN+"\n"); 224 225 226 // testNet.p.flush(); 227 228 Object lock = new Object(); 229 230 // Object synLock = new Object(); 231 // ListenInput listen = new ListenInput(testNet,lock); 232 // PCommunicationThread 233 // p1 = new PCommunicationThread(testNet, lock); 234 // PComputationThread p2 = new PComputationThread(testNet, lock); 235 236 final PRun p1 = new PRun ( 237 testNet.getDiscreteEventQueue ( ), 238 testNet, 239 lock, 240 barrier ); 241 242 // pas.ls.cellmap=null; 243 244 System.gc ( ); 245 246 final Thread run = new Thread ( p1 ); 247 248 run.setDaemon ( true ); 249 250 run.start ( ); 251 252 // Barrier Sync 253 254 jpvmBuffer buf = new jpvmBuffer(); 255 256 // send out ready info; 257 258 final String 259 messageString 260 = "NetHost " + jpvmInfo.jpvm.pvm_mytid ( ).toString ( ) 261 + " is ready to go"; 262 263 buf.pack ( messageString ); 264 265 LOGGER.info ( messageString ); 266 267 jpvmTaskId 268 jpvmTaskIdInstance = jpvmInfo.tids [ jpvmInfo.idIndex ]; 269 270 if ( jpvmTaskIdInstance == null ) 271 { 272 LOGGER.warn ( "jpvmTaskIdInstance == null" ); 273 274 // TODO: This is a temporary hack for JUnit testing. 275 276 jpvmTaskIdInstance = jpvmInfo.jpvm.pvm_mytid ( ); 277 } 278 279 jpvmInfo.jpvm.pvm_send ( 280 buf, 281 jpvmTaskIdInstance, 282 NetMessageTag.readySig ); 283 284 // m = info.jpvm.pvm_recv(NetMessageTag.readySig); 285 286 // Barrier Sync 287 288 while ( !testNet.stop ) 289 { 290 // receive info from others 291 292 final jpvmMessage m = testNet.info.jpvm.pvm_recv ( ); 293 294 if ( m.messageTag == NetMessageTag.trialDone ) 295 { 296 synchronized(lock) 297 { 298 testNet.trialDone = false; 299 } 300 } 301 302 // synchronized(lock) 303 { 304 // testNet.p.println("message "+m.messageTag); 305 306 // lock.notify(); 307 308 switch ( m.messageTag ) 309 { 310 case NetMessageTag.sendSpike: 311 312 processSendSpike ( 313 lock, 314 m, 315 testNet, 316 jpvmInfo ); 317 318 break; 319 320 case NetMessageTag.syncRoot: 321 322 // if its a message about time 323 324 processSyncRoot ( 325 lock, 326 testNet, 327 m ); 328 329 break; 330 331 case NetMessageTag.stopSig: 332 333 // if its a message about time 334 335 processStopSig ( 336 testNet, 337 jpvmInfo, 338 lock ); 339 340 break; 341 342 case NetMessageTag.tempStopSig: 343 344 //if its a message about time 345 346 processTempStopSig ( 347 testNet, 348 jpvmInfo ); 349 350 break; 351 352 case NetMessageTag.trialDone: 353 354 // new trial begins 355 356 processTrialDone ( 357 lock, 358 barrier, 359 m, 360 testNet ); 361 362 break; 363 364 case NetMessageTag.changeConnection: 365 366 processChangeConnection ( 367 m, 368 impl, 369 simulatorParser, 370 testNet, 371 jpvmInfo ); 372 373 break; 374 375 case NetMessageTag.netHostNotify: 376 377 processNetHostNotify ( jpvmInfo ); 378 379 break; 380 381 case NetMessageTag.resetNetHost: 382 383 processResetNetHost ( 384 lock, 385 testNet, 386 jpvmInfo ); 387 388 break; 389 390 case NetMessageTag.checkTime: 391 392 processCheckTime ( 393 m, 394 testNet, 395 p1, 396 jpvmInfo ); 397 398 break; 399 } 400 } 401 } 402 } 403 404 //////////////////////////////////////////////////////////////////////// 405 //////////////////////////////////////////////////////////////////////// 406 407 public static SimulatorParser createSimulatorParser ( 408 final DOMImplementationLS impl, 409 final byte [ ] byteArray, 410 final int seedInt, 411 final JpvmInfo jpvmInfo ) 412 throws Exception, jpvmException 413 //////////////////////////////////////////////////////////////////////// 414 { 415 final LSInput input = impl.createLSInput ( ); 416 417 input.setByteStream ( new ByteArrayInputStream ( byteArray ) ); 418 419 final LSParser parser = impl.createLSParser ( 420 DOMImplementationLS.MODE_SYNCHRONOUS, 421 null ); 422 423 final SimulatorParser simulatorParser = new SimulatorParser ( 424 new Seed ( seedInt - jpvmInfo.idIndex ), 425 parser.parse ( input ) ); 426 427 simulatorParser.parseMapCells ( jpvmInfo.idIndex ); 428 429 // p.println("cell maped"); 430 // System.out.println(pas.ls.base+ " "+pas.ls.neuron_end); 431 432 simulatorParser.parseNeuronDef ( ); 433 434 simulatorParser.parsePopNeurons ( jpvmInfo.idIndex ); 435 436 // p.println("cell poped"); 437 438 simulatorParser.parseScaffold ( jpvmInfo.idIndex ); 439 440 simulatorParser.layerStructure.buildStructure ( jpvmInfo.idIndex ); 441 442 simulatorParser.parseConnection ( jpvmInfo.idIndex ); 443 444 simulatorParser.parseTarget ( jpvmInfo ); 445 446 // sort the synapses, not necessary unless tune the parameters 447 448 // pas.ls.sortSynapses(info.idIndex); 449 // p.println("connected"); 450 451 simulatorParser.parseExp ( jpvmInfo.idIndex ); 452 453 // p.println("exp"); 454 455 simulatorParser.findMinDelay ( ); 456 457 // p.close(); 458 459 if ( simulatorParser.layerStructure.axons == null ) 460 { 461 throw new RuntimeException ( "no axon info" ); 462 } 463 464 return simulatorParser; 465 } 466 467 public static void processCheckTime ( 468 final jpvmMessage m, 469 final Network testNet, 470 final PRun pRun, 471 final JpvmInfo jpvmInfo ) 472 throws jpvmException 473 //////////////////////////////////////////////////////////////////////// 474 { 475 // testNet.p.println("check time now"); 476 477 // testNet.p.flush(); 478 479 final jpvmBuffer buf = new jpvmBuffer ( ); 480 481 // send the available Host id 482 483 buf.pack ( m.buffer.upkint ( ) ); 484 485 buf.pack ( testNet.subExpId ); 486 487 buf.pack ( pRun.minTime ); 488 489 buf.pack ( testNet.trialId ); 490 491 jpvmInfo.jpvm.pvm_send ( 492 buf, 493 jpvmInfo.tids [ jpvmInfo.idIndex ], 494 NetMessageTag.checkTime ); 495 } 496 497 public static void processChangeConnection ( 498 final jpvmMessage m, 499 final DOMImplementationLS impl, 500 final SimulatorParser simulatorParser, 501 final Network testNet, 502 final JpvmInfo jpvmInfo ) 503 throws jpvmException, Exception 504 //////////////////////////////////////////////////////////////////////// 505 { 506 final int seedInt = m.buffer.upkint ( ); 507 508 final int baLength = m.buffer.upkint ( ); 509 510 final byte [ ] ba = new byte [ baLength ]; 511 512 m.buffer.unpack ( ba, baLength, 1 ); 513 514 // DOMImplementationRegistry 515 // registry = DOMImplementationRegistry.newInstance(); 516 517 // DOMImplementationLS impl = (DOMImplementationLS) 518 // registry.getDOMImplementation("LS"); 519 520 final LSInput input = impl.createLSInput(); 521 522 input.setByteStream ( new ByteArrayInputStream ( ba ) ); 523 524 final LSParser parser = impl.createLSParser ( 525 DOMImplementationLS.MODE_SYNCHRONOUS, 526 null ); 527 528 final NodeList 529 conns = simulatorParser.rootElement.getElementsByTagName ( "Connections" ); 530 531 testNet.p.println("connection num"+conns.getLength()); 532 533 simulatorParser.rootElement.removeChild ( conns.item ( 0 ) ); 534 535 final Node dup = simulatorParser.document.importNode ( 536 parser.parse(input).getDocumentElement() 537 .getElementsByTagName("Connections").item(0), 538 true ); 539 540 simulatorParser.rootElement.appendChild ( dup ); 541 542 double weight; 543 544 // change the connections; 545 546 weight = simulatorParser.parseChangeConnection ( 547 jpvmInfo.idIndex ); 548 549 // synchronize 550 // testNet.p.println( 551 // "connection change done with weight "+weight); 552 553 testNet.seed = new Seed ( seedInt - jpvmInfo.idIndex); 554 555 // testNet.p.println("new seed"+testNet.idum.seed); 556 557 final jpvmBuffer buf1 = new jpvmBuffer ( ); 558 559 if ( weight < 0 ) 560 { 561 buf1.pack ( 562 "NetHost "+ jpvmInfo.jpvm.pvm_mytid().getHost() 563 +" has been changed"); //send out ready info; 564 } 565 else 566 { 567 // send out ready info 568 569 buf1.pack ( "badweight$" + weight ); 570 } 571 572 jpvmInfo.jpvm.pvm_send ( 573 buf1, 574 jpvmInfo.tids[jpvmInfo.idIndex], 575 NetMessageTag.readySig ); 576 577 //end of sync 578 579 if(weight < 0 ) 580 { 581 final jpvmBuffer buf2 = new jpvmBuffer(); 582 583 jpvmInfo.jpvm.pvm_send ( 584 buf2, 585 jpvmInfo.parentJpvmTaskId, 586 NetMessageTag.trialDone ); 587 } 588 } 589 590 public static void processNetHostNotify ( 591 final JpvmInfo jpvmInfo ) 592 throws jpvmException 593 //////////////////////////////////////////////////////////////////////// 594 { 595 // testNet.p.println("nethost notify"); 596 597 final jpvmBuffer buf1 = new jpvmBuffer ( ); 598 599 // send out ready info 600 601 buf1.pack ( 602 "NetHost " + jpvmInfo.jpvm.pvm_mytid ( ).toString ( ) 603 + " is ready to go" ); 604 605 jpvmInfo.jpvm.pvm_send ( 606 buf1, 607 jpvmInfo.tids [ jpvmInfo.idIndex ], 608 NetMessageTag.readySig ); 609 610 // restore saved seed for comparison; 611 // testNet.idum.seed = testNet.saveSeed; 612 613 final jpvmBuffer buf2 = new jpvmBuffer ( ); 614 615 jpvmInfo.jpvm.pvm_send ( 616 buf2, 617 jpvmInfo.parentJpvmTaskId, 618 NetMessageTag.trialDone ); 619 } 620 621 public static void processResetNetHost ( 622 final Object lock, 623 final Network testNet, 624 final JpvmInfo jpvmInfo ) 625 throws jpvmException 626 //////////////////////////////////////////////////////////////////////// 627 { 628 synchronized(lock) 629 { 630 // break; 631 632 testNet.trialDone = true; 633 634 // added; 635 636 testNet.spikeState = true; 637 638 for ( int iter = 0; iter < testNet.info.numTasks; iter++ ) 639 { 640 /* 641 while(!testNet.received[iter].empty()) 642 { 643 testNet.received[iter].pop(); 644 } 645 */ 646 647 // leave mark here 648 649 testNet.received [ iter ] = 1; 650 } 651 652 //added over; 653 654 // initilization 655 // testNet.rootTime=0.0; 656 657 testNet.recorderData.clear(); 658 659 testNet.clearQueues ( ); 660 661 testNet.countTrial++; 662 663 // testNet.p.println("reset the trial now"); 664 665 testNet.recordBuff.buff.clear(); 666 667 testNet.intraRecBuffers.init(); 668 669 for ( int i = 0; i < jpvmInfo.numTasks; i++ ) 670 { 671 testNet.spikeBuffers [ i ].buff.clear ( ); 672 } 673 674 // testNet.fireQueue.insertItem( 675 // new FireEvent( 676 // testNet.neurons.length-1+testNet.base, 677 // testNet.endOfTrial-testNet.minDelay/2.0)); 678 679 // for(int i=0; i<testNet.neurons.length-1; i++) 680 // { 681 // if(testNet.neurons[i].isSensory()) 682 // { 683 // // sensory neuron send spikes to the other neurons 684 // 685 // fireQueue.insertItem( 686 // new FireEvent( 687 // i+base, 688 // neurons[i].updateFire() )); 689 // } 690 // else 691 // { 692 // // nonsensory neurons will be initiazed; 693 // 694 // testNet.neurons[i].init(idum); 695 // } 696 // } 697 698 lock.notify(); 699 700 while ( jpvmInfo.jpvm.pvm_probe ( ) ) 701 { 702 // clear buffer 703 704 final jpvmMessage m = testNet.info.jpvm.pvm_recv ( ); 705 706// TODO: Are this messages supposed to be ignored? 707 } 708 709 final jpvmBuffer buf1 = new jpvmBuffer ( ); 710 711 buf1.pack ( "NetHost "+jpvmInfo.jpvm.pvm_mytid().toString() 712 +" is ready to go"); //send out ready info; 713 714 jpvmInfo.jpvm.pvm_send ( 715 buf1, 716 jpvmInfo.tids[jpvmInfo.idIndex], 717 NetMessageTag.readySig ); 718 719 // restore saved seed for comparison; 720 // testNet.idum.seed = testNet.saveSeed; 721 722 final jpvmBuffer buf2 = new jpvmBuffer ( ); 723 724 jpvmInfo.jpvm.pvm_send ( 725 buf2, 726 jpvmInfo.parentJpvmTaskId, 727 NetMessageTag.trialDone); 728 729 // testNet.p.println("reset done"); 730 } 731 } 732 733 public static void processSendSpike ( 734 final Object lock, 735 final jpvmMessage m, 736 final Network testNet, 737 final JpvmInfo jpvmInfo ) 738 throws jpvmException 739 //////////////////////////////////////////////////////////////////////// 740 { 741 synchronized ( lock ) 742 { 743 int sourceID = m.buffer.upkint ( ); 744 745 int trialID = m.buffer.upkint ( ); 746 747 if ( trialID == testNet.countTrial ) 748 { 749 // testNet.p.println ( "received and processed" ); 750 751 testNet.spikeState = true; 752 753 ( testNet.received [ sourceID ] )++; 754 755 for ( int iter = 0; iter < jpvmInfo.numTasks; iter++ ) 756 { 757 if ( iter != jpvmInfo.idIndex 758 && testNet.received [ iter ] == 0 ) 759 { 760 testNet.spikeState = false; 761 } 762 } 763 764 final SpikeBuffer 765 sbuff = ( SpikeBuffer ) m.buffer.upkcnsobj ( ); 766 767 final Iterator<NetMessage> iter = sbuff.buff.iterator ( ); 768 769 while ( iter.hasNext ( ) ) 770 { 771 final NetMessage message = iter.next ( ); 772 773 final Integer fromInteger = Integer.valueOf ( message.from ); 774 775 // try { 776 777 for ( final Branch branch 778 : testNet.axons.get ( fromInteger ).branches ) 779 { 780 testNet.getInputEventSlot ( ).offer ( 781 new InputEvent ( 782 message.time + branch.delay, 783 branch, 784 message.from ) ); //new input events 785 } 786 787 // } 788 // catch(Exception ex) 789 // { 790 // throw new RuntimeException ( 791 // ex.getMessage()+"\n from:"+message.from 792 // +" host id:"+info.idIndex+" axons" 793 // +testNet.axons.size()); 794 // } 795 } 796 797 lock.notify ( ); 798 } 799 /* 800 else 801 { 802 // testNet.p.println("received and ignored"); 803 } 804 */ 805 } 806 } 807 808 public static void processStopSig ( 809 final Network testNet, 810 final JpvmInfo jpvmInfo, 811 final Object lock ) 812 throws jpvmException 813 //////////////////////////////////////////////////////////////////////// 814 { 815 testNet.p.println ( 816 "get stop message root " + testNet.rootTime ); 817 818 testNet.p.flush ( ); 819 820 final jpvmBuffer buf = new jpvmBuffer ( ); 821 822 buf.pack ( testNet.recorderData ); 823 824 buf.pack ( jpvmInfo.idIndex ); 825 826 jpvmInfo.jpvm.pvm_send ( 827 buf, 828 jpvmInfo.tids [ jpvmInfo.idIndex ], 829 NetMessageTag.getBackData ); 830 831 testNet.clearQueues ( ); 832 833 testNet.stop = true; 834 835 testNet.p.close ( ); 836 837 synchronized ( lock ) 838 { 839 lock.notify ( ); 840 } 841 } 842 843 public static void processSyncRoot ( 844 final Object lock, 845 final Network testNet, 846 final jpvmMessage m ) 847 throws jpvmException 848 //////////////////////////////////////////////////////////////////////// 849 { 850 synchronized ( lock ) 851 { 852 if ( !testNet.trialDone ) 853 { 854 testNet.rootTime = m.buffer.upkdouble ( ); 855 856 lock.notify ( ); 857 } 858 } 859 } 860 861 public static void processTempStopSig ( 862 final Network testNet, 863 final JpvmInfo jpvmInfo ) 864 throws jpvmException 865 //////////////////////////////////////////////////////////////////////// 866 { 867 final jpvmBuffer buf = new jpvmBuffer ( ); 868 869 buf.pack ( testNet.recorderData ); 870 871 buf.pack ( jpvmInfo.idIndex ); 872 873 jpvmInfo.jpvm.pvm_send ( 874 buf, 875 jpvmInfo.tids [ jpvmInfo.idIndex ], 876 NetMessageTag.getBackData ); 877 878 testNet.recorderData.clear ( ); 879 } 880 881 public static void processTrialDone ( 882 final Object lock, 883 final CyclicBarrier barrier, 884 final jpvmMessage m, 885 final Network testNet ) 886 throws jpvmException, InterruptedException, BrokenBarrierException 887 //////////////////////////////////////////////////////////////////////// 888 { 889 890 // testNet.p.println("begin notifying"); 891 // 892 // System.out.println( 893 // "start"+testNet.subExpId+" "+testNet.trialId); 894 895 synchronized ( lock ) 896 { 897 barrier.await ( ); 898 899 testNet.trialId = m.buffer.upkint ( ); 900 901 testNet.subExpId = m.buffer.upkint ( ); 902 903 testNet.endOfTrial 904 = testNet.experiment.subExp [ testNet.subExpId ].trialLength; 905 906 Thread.yield ( ); 907 908 Thread.yield ( ); 909 910 // synchronized (synLock) 911 // { 912 // synLock.notify(); 913 // 914 // testNet.startSig=true; 915 // } 916 917 lock.notify ( ); 918 } 919 } 920 921 //////////////////////////////////////////////////////////////////////// 922 //////////////////////////////////////////////////////////////////////// 923 }