1 / 9

Synchronous Javascript ( = Javascript-CSP) C. Petitpierre, EPFL, Switzerland

Synchronous Javascript ( = Javascript-CSP) C. Petitpierre, EPFL, Switzerland. http://ltiwww.epfl.ch/sJavascript/SJSources/Plant.html http://ltiwww.epfl.ch/sJavascript. An example. Generator. Channel . when (ON) waituntil(now()+ 2 000) chan.put(x). Consumer.

jafari
Télécharger la présentation

Synchronous Javascript ( = Javascript-CSP) C. Petitpierre, EPFL, Switzerland

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. Synchronous Javascript( = Javascript-CSP)C. Petitpierre, EPFL, Switzerland http://ltiwww.epfl.ch/sJavascript/SJSources/Plant.html http://ltiwww.epfl.ch/sJavascript

  2. An example Generator Channel when (ON) waituntil(now()+2000) chan.put(x) Consumer when (parcel available) accept get when (place available) accept put when (ON) chan.get(x) sinkStart.clicked() ON = ! ON startStop.clicked() ON = ! ON sinkStop waituntil(now()+1000) startStop

  3. Synchronous Javascript Creates a concept close to the threads Synchronization inspired form CSP/CCS Merges the concepts of thread and object Runs on all browsers

  4. Source of the channel process Channel(name) { var fifo = new Array(0) this.put = function(data) { fifo.push(data) } this.get = function(data) { return fifo.shift() } this.run = function() { for (;;) { select { case when (fifo.length>0) accept get case when (fifo.length<6) accept put } showChannel(fifo.length) } } } Interface Scheduling

  5. The (weird) trick to introduce pseudo-concurency Scheduler this.run = function() { for (;;) { switch(this.$J_state) { case 10000: this.$J_init() // select statement if ((fifo.length>0)) { this.$J_accept(10003, this.$JM_get) } if ((fifo.length<6)) { this.$J_accept(10004, this.$JM_put) } if (this.$J_syncWait(17)) { break } else { return } . . . case 10003: . . . case 10004: . . . }}}

  6. Introduction of concurrency this.run = function() { for (;;) { switch(this.$J_state) { case 10000: . . . case 10003: this.$J_state = 10002 break case 10004: case 10002: showChannel(fifo.length) this.$J_state = 10000; } } } JUMP ( basis for any compiler )

  7. Kernel • ready process list • waiting process list • list of processes waiting for synchronization accept method1 method2 call object3/method3 object4/method4 accept method3 call object4/method5 object1/method2

  8. Kernel 1 2 scheduler syncWait syncWait 3 break (partner found) return (no partner) kill (return, registered in no list) 4 5 6 7

  9. Connection Listener-Synch Objects process Button(name) { this.clicked = function() {} this.data = 0 // no run method this.synchronize = function(data) { if (this.inSyncList) return this.data = data accept clicked // non blocking } }

More Related