Synchronous Javascript JavascriptCSP C' Petitpierre, EPFL, Switzerland - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Synchronous Javascript JavascriptCSP C' Petitpierre, EPFL, Switzerland

Description:

http://ltiwww.epfl.ch/sJavascript/SJSources/Plant.html. http://ltiwww. ... Merges the concepts of thread and object. Runs on all browsers. Source of the channel ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 10
Provided by: Petitp5
Category:

less

Transcript and Presenter's Notes

Title: Synchronous Javascript JavascriptCSP C' Petitpierre, EPFL, Switzerland


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.lengthgt0) accept
get case when (fifo.lengthlt6)
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.lengthgt0)) this.J_accept(10003
, this.JM_get) if
((fifo.lengthlt6)) 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
  • scheduler
  • syncWait
  • syncWait

2
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
Write a Comment
User Comments (0)
About PowerShow.com