Permalink
Browse files

Cleanup green_threads/kill_threads merge, builds now

  • Loading branch information...
1 parent b4834a4 commit 856f3b2507c87857867bf2cf451586e354695e7d @niner niner committed Sep 25, 2011
View
@@ -26,8 +26,6 @@
but that would be really annoying */
#if defined(PARROT_IN_CORE)
-#include "parrot/threads.h"
-
#else
typedef Parrot_Int Parrot_Language;
@@ -130,8 +130,6 @@ typedef Parrot_Run_core_t Run_Cores;
#include "parrot/call.h"
#include "parrot/gc_api.h"
-#include "parrot/thread.h"
-
typedef struct warnings_t {
Warnings_classes classes;
} *Warnings;
@@ -220,6 +218,7 @@ struct parrot_interp_t {
PMC *root_namespace; /* namespace hash */
PMC *scheduler; /* concurrency scheduler */
+ PMC *cur_task;
MMD_Cache *op_mmd_cache; /* MMD cache for builtins. */
@@ -237,6 +236,9 @@ struct parrot_interp_t {
int current_runloop_level; /* for reentering run loop */
int current_runloop_id;
+ UINTVAL last_alarm; /* has an alarm triggered? */
+ FLOATVAL quantum_done; /* expiration of current quantum */
+
UINTVAL recursion_limit; /* Sub call recursion limit */
/* during a call sequencer the caller fills these objects
View
@@ -1,187 +0,0 @@
-/* Copyright (C) 2010, Parrot Foundation.
- * $Id$
- */
-
-#ifndef PARROT_THREADS_H_GUARD
-#define PARROT_THREADS_H_GUARD
-
-#include "parrot/parrot.h"
-#include "parrot/thread.h"
-
-enum Thread_states {
- THREAD_STATE_INITIALIZED = 0x01, /* Thread has been created */
- THREAD_STATE_RUNNABLE = 0x02, /* We could signal this thread and it would run */
- THREAD_STATE_SCAN_STACK = 0x04, /* This thread may have PMCs on its stack */
- THREAD_STATE_RESTLESS = 0x08, /* This thread wants to run ASAP */
- THREAD_STATE_DEATH_MARK = 0x10 /* This thread is marked for death */
-};
-
-#define THREAD_STATE_TEST(interp, tidx, flag) \
- ((interp)->thread_table->threads[(tidx)].state & (THREAD_STATE_ ## flag))
-#define THREAD_STATE_SET(interp, tidx, flag) \
- ((interp)->thread_table->threads[(tidx)].state |= (THREAD_STATE_ ## flag))
-#define THREAD_STATE_CLEAR(interp, tidx, flag) \
- ((interp)->thread_table->threads[(tidx)].state &= ~(THREAD_STATE_ ## flag))
-
-typedef struct Thread_info {
- Parrot_thread id;
- INTVAL state;
- Parrot_cond cvar;
- void *lo_var_ptr; /* Full range of stack for GC scan */
- void *hi_var_ptr;
- PMC *cur_task;
-} Thread_info;
-
-typedef struct Thread_table {
- Thread_info *threads;
- INTVAL size;
- INTVAL count;
- Parrot_tls_key tid_key;
-} Thread_table;
-
-typedef struct Thread_args {
- Interp* interp;
- INTVAL idx;
-} Thread_args;
-
-#define LOCK_INTERP(interp) \
- LOCK((interp)->interp_lock)
-
-#define UNLOCK_INTERP(interp) \
- UNLOCK((interp)->interp_lock)
-
-#define BLOCK_THREAD_ON(interp, blocking_call) \
- do { \
- INTVAL tid, runloop_id, runloop_level; \
- PMC *context = Parrot_pmc_new((interp), enum_class_Continuation); \
- runloop_id = interp->current_runloop_id; \
- runloop_level = interp->current_runloop_level; \
- Parrot_threads_block((interp), &tid); \
- blocking_call; \
- Parrot_threads_unblock((interp), &tid); \
- (void) VTABLE_invoke((interp), context, 0); \
- interp->current_runloop_id = runloop_id; \
- interp->current_runloop_level = runloop_level; \
- } while (0)
-
-/* HEADERIZER BEGIN: src/threads.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-void Parrot_check_if_task_killed(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_threads_block(PARROT_INTERP, ARGOUT(INTVAL *tidx))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*tidx);
-
-INTVAL Parrot_threads_check_and_reset(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_threads_cleanup(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-INTVAL Parrot_threads_count_active(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-INTVAL Parrot_threads_current(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_threads_gc_mark(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_threads_idle(PARROT_INTERP, INTVAL tidx)
- __attribute__nonnull__(1);
-
-void Parrot_threads_init(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_CAN_RETURN_NULL
-void* Parrot_threads_main(ARGMOD(void *args_ptr))
- __attribute__nonnull__(1)
- FUNC_MODIFIES(*args_ptr);
-
-INTVAL Parrot_threads_next_to_run(PARROT_INTERP, INTVAL cur_idx)
- __attribute__nonnull__(1);
-
-void Parrot_threads_outer_runloop(PARROT_INTERP, INTVAL tidx)
- __attribute__nonnull__(1);
-
-void Parrot_threads_print_table(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_threads_reap(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_threads_set_signal(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_threads_setup_signal_handler(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_threads_spawn(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-void Parrot_threads_task_killed(PARROT_INTERP, INTVAL tidx)
- __attribute__nonnull__(1);
-
-void Parrot_threads_task_killed_handler(int sig_number);
-void Parrot_threads_unblock(PARROT_INTERP, ARGIN(INTVAL *tidx_ptr))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-#define ASSERT_ARGS_Parrot_check_if_task_killed __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_block __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(tidx))
-#define ASSERT_ARGS_Parrot_threads_check_and_reset \
- __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_cleanup __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_count_active __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_current __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_gc_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_idle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_init __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_main __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(args_ptr))
-#define ASSERT_ARGS_Parrot_threads_next_to_run __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_outer_runloop __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_print_table __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_reap __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_set_signal __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_setup_signal_handler \
- __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_spawn __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_task_killed __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_threads_task_killed_handler \
- __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
-#define ASSERT_ARGS_Parrot_threads_unblock __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(tidx_ptr))
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-/* HEADERIZER END: src/threads.c */
-
-#endif /* PARROT_THREADS_H_GUARD */
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
View
@@ -25,7 +25,6 @@ numbered. You probably want src/embed/api.c
#include "pmc/pmc_sub.h"
#include "pmc/pmc_callcontext.h"
#include "parrot/runcore_api.h"
-#include "parrot/threads.h"
#include "parrot/oplib/core_ops.h"
#include "imcc/embed.h"
View
@@ -106,11 +106,6 @@ Parrot_x_exit(PARROT_INTERP, int status)
*/
handler_node_t *node;
- INTVAL tidx = Parrot_threads_current(interp);
- if (tidx != 0) {
- exit(status);
- }
-
node = interp->exit_handler_list;
Parrot_block_GC_mark(interp);
View
@@ -90,7 +90,6 @@ implementation, and malloc wrappers for various purposes. These are unused.
#define GC_C_SOURCE
#include "parrot/parrot.h"
#include "parrot/gc_api.h"
-#include "parrot/threads.h"
#include "gc_private.h"
#include "fixed_allocator.h"
@@ -188,7 +187,7 @@ Parrot_gc_initialize(PARROT_INTERP, ARGIN(Parrot_GC_Init_Args *args))
{
ASSERT_ARGS(Parrot_gc_initialize)
- interp->thread_table->threads[0].lo_var_ptr = args->stacktop;
+ interp->lo_var_ptr = args->stacktop;
interp->gc_sys->sys_type = PARROT_GC_DEFAULT_TYPE;
View
@@ -229,7 +229,6 @@ mark_interp(PARROT_INTERP)
/* mark the concurrency scheduler and tasks */
Parrot_gc_mark_PMC_alive(interp, interp->scheduler);
- Parrot_threads_gc_mark(interp);
/* mark caches and freelists */
mark_object_cache(interp);
View
@@ -26,7 +26,6 @@ TT #273: This file needs to be cleaned up significantly.
*/
#include "parrot/parrot.h"
-#include "parrot/threads.h"
#include "gc_private.h"
/* HEADERIZER HFILE: src/gc/gc_private.h */
@@ -237,27 +236,11 @@ trace_system_stack(PARROT_INTERP, ARGIN_NULLOK(const Memory_Pools *mem_pools))
"top" of the stack. A value stored in interp->lo_var_ptr represents
the "bottom" of the stack. We must trace the entire area between the
top and bottom. */
- const Thread_table *tbl = interp->thread_table;
- int i, cur_idx;
-
- /* We need to trace the stack in one running thread (this thread) as
- well as the stack in each other active thread.
- */
- cur_idx = Parrot_threads_current(interp);
-
- for (i = 0; i < tbl->count; ++i) {
- void *lo = tbl->threads[i].lo_var_ptr;
-
- if (i == cur_idx) {
- void *hi = &i;
- trace_mem_block(interp, mem_pools, (size_t)lo, (size_t)hi);
- }
- else if (THREAD_STATE_TEST(interp, i, SCAN_STACK)) {
- void *hi = tbl->threads[i].hi_var_ptr;
- trace_mem_block(interp, mem_pools, (size_t)lo, (size_t)hi);
- }
- }
+ const size_t lo_var_ptr = (size_t)interp->lo_var_ptr;
+ PARROT_ASSERT(lo_var_ptr);
+ trace_mem_block(interp, mem_pools, (size_t)lo_var_ptr,
+ (size_t)&lo_var_ptr);
}
/*
@@ -228,9 +228,6 @@ initialize_interpreter(PARROT_INTERP, ARGIN(Parrot_GC_Init_Args *args))
{
ASSERT_ARGS(initialize_interpreter)
- /* Need threads table to init gc */
- Parrot_threads_init(interp);
-
/* Set up the memory allocation system */
Parrot_gc_initialize(interp, args);
Parrot_block_GC_mark(interp);
View
@@ -13336,7 +13336,7 @@ Parrot_load_language_sc(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_branch_i(opcode_t *cur_opcode, PARROT_INTERP) {
if ((Parrot_cx_check_scheduler(interp, (cur_opcode + IREG(1))) == 0)) {
- (return0);
+ return 0;
}
return (opcode_t *)cur_opcode + IREG(1);
@@ -13345,7 +13345,7 @@ Parrot_branch_i(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_branch_ic(opcode_t *cur_opcode, PARROT_INTERP) {
if ((Parrot_cx_check_scheduler(interp, (cur_opcode + ICONST(1))) == 0)) {
- (return0);
+ return 0;
}
return (opcode_t *)cur_opcode + ICONST(1);
View
@@ -155,7 +155,7 @@ Retrieves the number of pending tasks in the scheduler's task list.
VTABLE INTVAL get_integer() {
Parrot_Scheduler_attributes * core_struct = PARROT_SCHEDULER(SELF);
- return VTABLE_elements(INTERP, core_struct->task_index);
+ return VTABLE_elements(INTERP, core_struct->task_queue);
}
View
@@ -31,7 +31,6 @@ pmclass Task provides invokable auto_attrs {
ATTR PMC *code; /* An (optional) code for the task */
ATTR PMC *data; /* Additional data for the task */
ATTR INTVAL killed; /* Dead tasks don't get run */
- ATTR INTVAL tidx; /* Which thread to signal if killed */
ATTR PMC *mailbox; /* List of incoming messages */
ATTR PMC *waiters; /* Tasks waiting on this one */
ATTR Parrot_jump_buff abort_jump; /* Jump buffer to abort task */
@@ -59,7 +58,6 @@ Initialize a concurrency task object.
core_struct->data = PMCNULL;
core_struct->interp = INTERP;
core_struct->killed = 0;
- core_struct->tidx = -1;
core_struct->mailbox = Parrot_pmc_new(interp, enum_class_PMCList);
core_struct->waiters = Parrot_pmc_new(interp, enum_class_ResizablePMCArray);
@@ -161,14 +159,12 @@ code as the first argument.
TASK_active_SET(SELF);
/* Actually run the task */
- task->tidx = Parrot_threads_current(interp);
if (PMC_IS_NULL(task->data)) {
Parrot_ext_call(interp, task->code, "->");
}
else {
Parrot_ext_call(interp, task->code, "P->", task->data);
}
- task->tidx = -1;
}
if (task->killed || !TASK_in_preempt_TEST(SELF)) {
@@ -403,10 +399,6 @@ Kill this task.
METHOD kill() {
Parrot_Task_attributes *tdata = PARROT_TASK(SELF);
tdata->killed = 1;
-
- if (tdata->tidx >= 0) {
- Parrot_threads_task_killed(interp, tdata->tidx);
- }
}
}
Oops, something went wrong.

0 comments on commit 856f3b2

Please sign in to comment.