Permalink
Browse files

fix add_first_link/add_last_link

2012-02-02  Paolo Bonzini  <bonzini@gnu.org>
            Gwenael Casaccio  <mrgwen@gmail.com>

	* tests/delays.st: Add testcase.
	* tests/delays.ok: Regenerate.

2012-02-02  Paolo Bonzini  <bonzini@gnu.org>
libgst:
2012-02-02  Gwenael Casaccio  <mrgwen@gmail.com>
            Paolo Bonzini  <pbonzini@redhat.com>

	* libgst/interp.c: Use remove_process_from_list consistently.
  • Loading branch information...
bonzini committed Feb 2, 2012
1 parent 4cc7672 commit 2169f34e1386d390cfe38240137c73494f58c5a0
Showing with 54 additions and 72 deletions.
  1. +6 −0 ChangeLog
  2. +6 −0 kernel/SysExcept.st
  3. +5 −0 libgst/ChangeLog
  4. +21 −72 libgst/interp.c
  5. +4 −0 tests/delays.ok
  6. +12 −0 tests/delays.st
View
@@ -1,3 +1,9 @@
+2012-02-02 Paolo Bonzini <bonzini@gnu.org>
+ Gwenael Casaccio <mrgwen@gmail.com>
+
+ * tests/delays.st: Add testcase.
+ * tests/delays.ok: Regenerate.
+
2012-02-02 Paolo Bonzini <bonzini@gnu.org>
* kernel/Process.st: Do not interrupt a terminated process.
View
@@ -1399,6 +1399,12 @@ to an end.'>
<category: 'private'>
^ false
]
+
+ defaultAction [
+ "We are not resumable, so do nothing. This should really never happen."
+
+ <category: 'exception description'>
+ ]
]
]
View
@@ -1,3 +1,8 @@
+2012-02-02 Gwenael Casaccio <mrgwen@gmail.com>
+ Paolo Bonzini <pbonzini@redhat.com>
+
+ * libgst/interp.c: Use remove_process_from_list consistently.
+
2011-12-14 Paolo Bonzini <pbonzini@redhat.com>
* libgst/gst-parse.c: Only increase lookahead by one token at
View
@@ -1375,51 +1375,6 @@ get_scheduled_process (void)
return (processor->activeProcess);
}
-void
-add_first_link (OOP semaphoreOOP,
- OOP processOOP)
-{
- gst_semaphore sem;
- gst_process process, lastProcess;
- OOP lastProcessOOP;
-
- process = (gst_process) OOP_TO_OBJ (processOOP);
- if (!IS_NIL (process->myList))
- {
- sem = (gst_semaphore) OOP_TO_OBJ (process->myList);
- if (sem->firstLink == processOOP)
- {
- sem->firstLink = process->nextLink;
- if (sem->lastLink == processOOP)
- {
- /* It was the only process in the list */
- sem->lastLink = _gst_nil_oop;
- }
- }
- else if (sem->lastLink == processOOP)
- {
- /* Find the new last link */
- lastProcessOOP = sem->firstLink;
- lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
- while (lastProcess->nextLink != processOOP)
- {
- lastProcessOOP = lastProcess->nextLink;
- lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
- }
- sem->lastLink = lastProcessOOP;
- lastProcess->nextLink = _gst_nil_oop;
- }
- }
-
- sem = (gst_semaphore) OOP_TO_OBJ (semaphoreOOP);
- process->myList = semaphoreOOP;
- process->nextLink = sem->firstLink;
-
- sem->firstLink = processOOP;
- if (IS_NIL (sem->lastLink))
- sem->lastLink = processOOP;
-}
-
static void
remove_process_from_list (OOP processOOP)
{
@@ -1444,7 +1399,7 @@ remove_process_from_list (OOP processOOP)
}
else
{
- /* Find the new last link */
+ /* Find the new prev node */
lastProcessOOP = sem->firstLink;
lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
while (lastProcess->nextLink != processOOP)
@@ -1464,6 +1419,25 @@ remove_process_from_list (OOP processOOP)
process->nextLink = _gst_nil_oop;
}
+void
+add_first_link (OOP semaphoreOOP,
+ OOP processOOP)
+{
+ gst_semaphore sem;
+ gst_process process;
+
+ process = (gst_process) OOP_TO_OBJ (processOOP);
+ remove_process_from_list (processOOP);
+
+ sem = (gst_semaphore) OOP_TO_OBJ (semaphoreOOP);
+ process->myList = semaphoreOOP;
+ process->nextLink = sem->firstLink;
+
+ sem->firstLink = processOOP;
+ if (IS_NIL (sem->lastLink))
+ sem->lastLink = processOOP;
+}
+
void
suspend_process (OOP processOOP)
{
@@ -1491,32 +1465,7 @@ add_last_link (OOP semaphoreOOP,
OOP lastProcessOOP;
process = (gst_process) OOP_TO_OBJ (processOOP);
- if (!IS_NIL (process->myList))
- {
- sem = (gst_semaphore) OOP_TO_OBJ (process->myList);
- if (sem->firstLink == processOOP)
- {
- sem->firstLink = process->nextLink;
- if (sem->lastLink == processOOP)
- {
- /* It was the only process in the list */
- sem->lastLink = _gst_nil_oop;
- }
- }
- else if (sem->lastLink == processOOP)
- {
- /* Find the new last link */
- lastProcessOOP = sem->firstLink;
- lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
- while (lastProcess->nextLink != processOOP)
- {
- lastProcessOOP = lastProcess->nextLink;
- lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
- }
- sem->lastLink = lastProcessOOP;
- lastProcess->nextLink = _gst_nil_oop;
- }
- }
+ remove_process_from_list (processOOP);
sem = (gst_semaphore) OOP_TO_OBJ (semaphoreOOP);
process->myList = semaphoreOOP;
View
@@ -30,3 +30,7 @@ returned value is 'timeout'
Execution begins...
returned value is true
+
+Execution begins...
+value:onTimeoutDo:
+returned value is nil
View
@@ -95,3 +95,15 @@ Eval [
^(Time millisecondsToRun: [ d wait ]) >= 500
]
+Eval [
+ | d1 d2 p1 p2 |
+ sem := Semaphore new.
+ d1 := Delay forSeconds: 1.
+ p1 := [ d1 value: [ sem signal ] onTimeoutDo: [ ] ] fork.
+ sem wait.
+
+ 'value:onTimeoutDo:' displayNl.
+ d1 := Delay forMilliseconds: 100.
+ d1 value: [ [ true ] whileTrue ] onTimeoutDo: [ ].
+ [ p1 isTerminated ] whileFalse: [ Processor yield ]
+]

0 comments on commit 2169f34

Please sign in to comment.