about summary refs log tree commit diff stats
path: root/html
diff options
context:
space:
mode:
Diffstat (limited to 'html')
-rw-r--r--html/075channel.mu.html4
-rw-r--r--html/088file.mu.html6
-rw-r--r--html/089scenario_filesystem.cc.html2
3 files changed, 10 insertions, 2 deletions
diff --git a/html/075channel.mu.html b/html/075channel.mu.html
index 42e8fda8..7b9ade33 100644
--- a/html/075channel.mu.html
+++ b/html/075channel.mu.html
@@ -45,6 +45,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
 <span class="Comment">#   b) Writing to a channel implicitly performs a deep copy. This prevents</span>
 <span class="Comment">#   addresses from being shared between routines, and therefore eliminates all</span>
 <span class="Comment">#   possibility of race conditions.</span>
+<span class="Comment">#</span>
+<span class="Comment"># There's still a narrow window for race conditions: the ingredients passed in</span>
+<span class="Comment"># to 'start-running'. Pass only channels into routines and you should be fine.</span>
+<span class="Comment"># Any other mutable ingredients will require locks.</span>
 
 <span class="muScenario">scenario</span> channel [
   run [
diff --git a/html/088file.mu.html b/html/088file.mu.html
index 26fa0c7c..46d9363a 100644
--- a/html/088file.mu.html
+++ b/html/088file.mu.html
@@ -35,6 +35,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
 <span class="Comment"># are thus easier to test.</span>
 
 <span class="muData">container</span> resources [
+  lock:bool
   data:&amp;:@:resource
 ]
 
@@ -117,7 +118,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   <span class="Delimiter">{</span>
     <span class="muControl">break-unless</span> resources
     <span class="Comment"># fake file system</span>
-    <span class="Comment"># beware: doesn't support multiple concurrent writes yet</span>
     routine-id <span class="Special">&lt;-</span> start-running transmit-to-fake-file resources, filename, source
     <span class="muControl">reply</span>
   <span class="Delimiter">}</span>
@@ -142,6 +142,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
 <span class="muRecipe">def</span> transmit-to-fake-file resources:&amp;:resources, filename:text, source:&amp;:source:char<span class="muRecipe"> -&gt; </span>resources:&amp;:resources, source:&amp;:source:char [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
+  lock:location <span class="Special">&lt;-</span> get-location *resources, <span class="Constant">lock:offset</span>
+  wait-for-reset-then-set lock
   <span class="Comment"># compute new file contents</span>
   buf:&amp;:buffer <span class="Special">&lt;-</span> new-buffer<span class="Constant"> 30</span>
   <span class="Delimiter">{</span>
@@ -166,6 +168,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
     found?:bool <span class="Special">&lt;-</span> equal filename, curr-filename
     <span class="muControl">loop-unless</span> found?
     put-index *data, i, new-resource
+    reset lock
     <span class="muControl">reply</span>
   <span class="Delimiter">}</span>
   <span class="Comment"># if file didn't already exist, make room for it</span>
@@ -182,6 +185,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   <span class="Delimiter">}</span>
   <span class="Comment"># write new file</span>
   put-index *new-data, len, new-resource
+  reset lock
 ]
 </pre>
 </body>
diff --git a/html/089scenario_filesystem.cc.html b/html/089scenario_filesystem.cc.html
index d1fb007d..608f9c25 100644
--- a/html/089scenario_filesystem.cc.html
+++ b/html/089scenario_filesystem.cc.html
@@ -258,7 +258,7 @@ string munge_resources_contents<span class="Delimiter">(</span><span class="Norm
   trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;mem&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;storing refcount 1 in location &quot;</span> &lt;&lt; resources_data_address &lt;&lt; end<span class="Delimiter">();</span>
   <span class="Comment">// wrap the resources data in a 'resources' object</span>
   <span class="Normal">int</span> resources_address = allocate<span class="Delimiter">(</span>size_of_resources<span class="Delimiter">());</span>
-  curr = resources_address+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span>
+  curr = resources_address+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">offset of 'data' element</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span>
   put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> resources_data_address<span class="Delimiter">);</span>
   trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;mem&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;storing resources data address &quot;</span> &lt;&lt; resources_data_address &lt;&lt; <span class="Constant">&quot; in location &quot;</span> &lt;&lt; curr &lt;&lt; end<span class="Delimiter">();</span>
   put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> resources_address<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span>  <span class="Comment">// initialize refcount</span>
a id='n370' href='#n370'>370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602