[svn:parrot] r48017 - in branches/gsoc_threads: . config/gen/makefiles include/parrot src
Chandon at svn.parrot.org
Chandon at svn.parrot.org
Tue Jul 6 21:08:39 UTC 2010
Author: Chandon
Date: Tue Jul 6 21:08:39 2010
New Revision: 48017
URL: https://trac.parrot.org/parrot/changeset/48017
Log:
[gsoc_threads] Now with less segfaults.
Deleted:
branches/gsoc_threads/include/parrot/alarm_private.h
Modified:
branches/gsoc_threads/MANIFEST
branches/gsoc_threads/config/gen/makefiles/root.in
branches/gsoc_threads/include/parrot/alarm.h
branches/gsoc_threads/include/parrot/scheduler.h
branches/gsoc_threads/src/alarm.c
branches/gsoc_threads/src/scheduler.c
Modified: branches/gsoc_threads/MANIFEST
==============================================================================
--- branches/gsoc_threads/MANIFEST Mon Jul 5 18:20:02 2010 (r48016)
+++ branches/gsoc_threads/MANIFEST Tue Jul 6 21:08:39 2010 (r48017)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Sun Jul 4 23:45:06 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Jul 6 19:02:41 2010 UT
#
# See below for documentation on the format of this file.
#
@@ -937,7 +937,6 @@
ext/nqp-rx/t/p6regex/rx_subrules [test]
ext/nqp-rx/t/p6regex/rx_syntax [test]
include/parrot/alarm.h [main]include
-include/parrot/alarm_private.h [main]include
include/parrot/atomic.h [main]include
include/parrot/atomic/fallback.h [main]include
include/parrot/atomic/gcc_pcc.h [main]include
Modified: branches/gsoc_threads/config/gen/makefiles/root.in
==============================================================================
--- branches/gsoc_threads/config/gen/makefiles/root.in Mon Jul 5 18:20:02 2010 (r48016)
+++ branches/gsoc_threads/config/gen/makefiles/root.in Tue Jul 6 21:08:39 2010 (r48017)
@@ -918,8 +918,7 @@
$(INC_DIR)/runcore_api.h
src/alarm$(O) : $(PARROT_H_HEADERS) src/alarm.c \
- $(INC_DIR)/alarm.h \
- $(INC_DIR)/alarm_private.h
+ $(INC_DIR)/alarm.h
src/io/core$(O) : $(PARROT_H_HEADERS) src/io/io_private.h src/io/core.c
Modified: branches/gsoc_threads/include/parrot/alarm.h
==============================================================================
--- branches/gsoc_threads/include/parrot/alarm.h Mon Jul 5 18:20:02 2010 (r48016)
+++ branches/gsoc_threads/include/parrot/alarm.h Tue Jul 6 21:08:39 2010 (r48017)
@@ -15,15 +15,11 @@
FUNC_MODIFIES(* last_serial);
PARROT_EXPORT
-void Parrot_alarm_init(void);
-
-PARROT_EXPORT
void Parrot_alarm_set(FLOATVAL when);
void Parrot_alarm_callback(NULLOK(int sig_number));
#define ASSERT_ARGS_Parrot_alarm_check __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(last_serial))
-#define ASSERT_ARGS_Parrot_alarm_init __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_alarm_set __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_alarm_callback __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
Deleted: branches/gsoc_threads/include/parrot/alarm_private.h
==============================================================================
--- branches/gsoc_threads/include/parrot/alarm_private.h Tue Jul 6 21:08:39 2010 (r48016)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,23 +0,0 @@
-/*
-Copyright (C) 2010, Parrot Foundation.
-$Id$
-*/
-
-#ifndef PARROT_ALARM_PRIVATE_H_GUARD
-#define PARROT_ALARM_PRIVATE_H_GUARD
-
-#include "parrot.h"
-
-typedef struct Parrot_alarm_queue {
- FLOATVAL when;
- struct Parrot_alarm_queue *next;
-} Parrot_alarm_queue;
-
-#endif /* PARROT_ALARM_PRIVATE_H_GUARD */
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
Modified: branches/gsoc_threads/include/parrot/scheduler.h
==============================================================================
--- branches/gsoc_threads/include/parrot/scheduler.h Mon Jul 5 18:20:02 2010 (r48016)
+++ branches/gsoc_threads/include/parrot/scheduler.h Tue Jul 6 21:08:39 2010 (r48017)
@@ -31,7 +31,7 @@
__attribute__nonnull__(2);
PARROT_EXPORT
-void Parrot_cx_begin_execution(PARROT_INTERP,
+void Parrot_cx_begin_execution(PARROT_INTERP,
ARGMOD(PMC *main),
ARGMOD(PMC *argv))
__attribute__nonnull__(1)
Modified: branches/gsoc_threads/src/alarm.c
==============================================================================
--- branches/gsoc_threads/src/alarm.c Mon Jul 5 18:20:02 2010 (r48016)
+++ branches/gsoc_threads/src/alarm.c Tue Jul 6 21:08:39 2010 (r48017)
@@ -10,13 +10,13 @@
*/
-#include "parrot/alarm_private.h"
+#include "parrot/parrot.h"
#include "parrot/alarm.h"
/* Some per-process state */
-static Parrot_alarm_queue* alarm_queue = NULL;
-static volatile UINTVAL alarm_serial = 0;
-static volatile UINTVAL alarm_init = 0;
+static volatile UINTVAL alarm_serial = 0;
+static volatile UINTVAL alarm_init = 0;
+static volatile FLOATVAL alarm_set_to = 0.0;
/* This file relies on POSIX. Probably need two other versions of it:
* one for Windows and one for platforms with no signals or threads. */
@@ -30,8 +30,10 @@
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-static void set_posix_alarm(FLOATVAL wait);
-#define ASSERT_ARGS_set_posix_alarm __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+static void posix_alarm_init(void);
+static void posix_alarm_set(FLOATVAL wait);
+#define ASSERT_ARGS_posix_alarm_init __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_posix_alarm_set __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
@@ -40,7 +42,7 @@
=over 4
-=item C<void Parrot_alarm_init(void)>
+=item C<static void posix_alarm_init(void)>
Initialize the alarm queue. This function should only be called from the initial
pthread. Any other pthreads should make sure to mask out SIGALRM.
@@ -51,11 +53,10 @@
void Parrot_alarm_callback(SHIM(int sig_number));
-PARROT_EXPORT
-void
-Parrot_alarm_init(void)
+static void
+posix_alarm_init(void)
{
- ASSERT_ARGS(Parrot_alarm_init)
+ ASSERT_ARGS(posix_alarm_init)
struct sigaction sa;
sa.sa_handler = Parrot_alarm_callback;
@@ -71,7 +72,7 @@
/*
-=item C<static void set_posix_alarm(FLOATVAL wait)>
+=item C<static void posix_alarm_set(FLOATVAL wait)>
A helper function to set an alarm.
@@ -80,16 +81,16 @@
*/
static void
-set_posix_alarm(FLOATVAL wait)
+posix_alarm_set(FLOATVAL wait)
{
- ASSERT_ARGS(set_posix_alarm)
+ ASSERT_ARGS(posix_alarm_set)
const int MIL = 1000000;
struct itimerval itmr;
int sec, usec;
if (!alarm_init)
- Parrot_alarm_init();
+ posix_alarm_init();
sec = (int) wait;
usec = (int) ((wait - sec) * MIL);
@@ -101,7 +102,7 @@
if (setitimer(ITIMER_REAL, &itmr, 0) == -1) {
if (errno == EINVAL) {
- raise(SIGALRM);
+ Parrot_alarm_callback(SIGALRM);
}
else {
perror("setitimer failed in set_posix_alarm");
@@ -126,24 +127,8 @@
{
ASSERT_ARGS(Parrot_alarm_callback)
- FLOATVAL now, wait;
- Parrot_alarm_queue* qp;
-
/* Not atomic; only one thread ever writes this value */
alarm_serial += 1;
-
- /* Find the first future item. */
- now = Parrot_floatval_time();
- while (alarm_queue != NULL && alarm_queue->when < now) {
- qp = alarm_queue->next;
- free(alarm_queue);
- alarm_queue = qp;
- }
-
- if (alarm_queue != NULL) {
- wait = alarm_queue->when - now;
- set_posix_alarm(wait);
- }
}
/*
@@ -190,33 +175,16 @@
{
ASSERT_ARGS(Parrot_alarm_set)
- Parrot_alarm_queue *new_alarm;
- Parrot_alarm_queue **qpp;
- FLOATVAL now;
+ FLOATVAL now = Parrot_floatval_time();
/* Better late than early */
when += 0.0001;
- now = Parrot_floatval_time();
-
- new_alarm = (Parrot_alarm_queue*) malloc(sizeof (Parrot_alarm_queue));
- new_alarm->when = when;
- new_alarm->next = NULL;
-
- if (alarm_queue == NULL || when < alarm_queue->when) {
- new_alarm->next = alarm_queue;
- alarm_queue = new_alarm;
- set_posix_alarm(when - now);
+ if (alarm_set_to > now && alarm_set_to < when)
return;
- }
-
- qpp = &alarm_queue;
- while (*qpp != NULL && (*qpp)->when < when) {
- qpp = &(alarm_queue->next);
- }
- new_alarm->next = *qpp;
- *qpp = new_alarm;
+ alarm_set_to = when;
+ posix_alarm_set(when - now);
}
/*
Modified: branches/gsoc_threads/src/scheduler.c
==============================================================================
--- branches/gsoc_threads/src/scheduler.c Mon Jul 5 18:20:02 2010 (r48016)
+++ branches/gsoc_threads/src/scheduler.c Tue Jul 6 21:08:39 2010 (r48017)
@@ -122,6 +122,7 @@
do {
Parrot_cx_reschedule(interp, scheduler);
task_count = VTABLE_get_integer(interp, sched->task_queue);
+ return;
} while (task_count > 0);
}
@@ -261,17 +262,18 @@
if (task_count > 0) {
FLOATVAL time_now = Parrot_floatval_time();
- PMC *task0 = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
+ /* PMC *task0 = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp)); */
PMC *task1 = VTABLE_shift_pmc(interp, sched->task_queue);
- if (!PMC_IS_NULL(task0))
- VTABLE_push_pmc(interp, sched->task_queue, task0);
+ /*if (!PMC_IS_NULL(task0))
+ VTABLE_push_pmc(interp, sched->task_queue, task0); */
interp->quantum_done = time_now + PARROT_TASK_SWITCH_QUANTUM;
Parrot_alarm_set(interp->quantum_done);
- if (!PMC_IS_NULL(task1))
+ if (!PMC_IS_NULL(task1)) {
Parrot_pcc_invoke_sub_from_c_args(interp, task1, "->");
+ }
}
}
@@ -954,6 +956,7 @@
Parrot_cx_schedule_immediate(interp, data->alarm_sub);
}
else {
+ Parrot_alarm_set(alarm_time);
VTABLE_unshift_pmc(interp, sched->alarms, alarm);
break;
}
More information about the parrot-commits
mailing list