}
/**
- * cothreads_stackquery:
- * @stack: Will be set to point to the allocated stack location
- * @stacksize: Will be set to the size of the allocated stack
- *
- * Returns: #TRUE on success, #FALSE otherwise.
- */
-gboolean
-cothread_stackquery (void **stack, glong* stacksize)
-{
- /* use either
- * - posix_memalign to allocate a 2M-aligned, 2M stack
- * or
- * - valloc
- *
- * memory allocated by either of these two can be freed using free ()
- * FIXME: define how the stack grows */
-
-#ifdef HAVE_POSIX_MEMALIGN
- int retval = posix_memalign (stack, STACK_SIZE, STACK_SIZE);
- if (retval != 0)
- {
- g_warning ("Could not posix_memalign stack !\n");
- if (retval == EINVAL)
- g_warning ("The alignment parameter %d was not a power of two !\n",
- STACK_SIZE);
- if (retval == ENOMEM)
- g_warning ("Insufficient memory to allocate the request of %d !\n",
- STACK_SIZE);
- *stacksize = 0;
- return FALSE;
- }
- GST_DEBUG (GST_CAT_THREAD, "have posix_memalign at %p of size %d",
- (void *) *stack, STACK_SIZE);
-#else
- if ((*stack = valloc (STACK_SIZE)) == NULL)
- {
- g_warning ("Could not valloc stack !\n");
- return FALSE;
- }
- GST_DEBUG (GST_CAT_THREAD, "have valloc at %p of size %d",
- (void *) *stack, STACK_SIZE);
-#endif
-
- GST_DEBUG (GST_CAT_COTHREADS,
- "Got new cothread stack from %p to %p (size %ld)",
- *stack, *stack + STACK_SIZE - 1, (long) STACK_SIZE);
- *stacksize = STACK_SIZE;
- return TRUE;
-}
-
-/**
* cothread_switch:
* @thread: cothread state to switch to
*
void cothread_stop (cothread_state *thread);
void cothread_switch (cothread_state *thread);
-gboolean cothread_stackquery (void **stack, glong* stacksize);
void cothread_set_private (cothread_state *thread,
gpointer data);
gpointer cothread_get_private (cothread_state *thread);
}
/**
- * gst_scheduler_get_preferred_stack:
- * @sched: a #GstScheduler to query.
- * @stack: the pointer to store the location of the preferred stack in.
- * @size: the pointer to store the size of the preferred stack in.
- *
- * Gets the preferred stack location and size of this scheduler.
- *
- * Returns: TRUE if the scheduler suggested a preferred stacksize and location.
- */
-gboolean
-gst_scheduler_get_preferred_stack (GstScheduler *sched, gpointer *stack, gulong *size)
-{
- g_return_val_if_fail (GST_IS_SCHEDULER (sched), FALSE);
-
- if (CLASS (sched)->get_preferred_stack)
- return CLASS (sched)->get_preferred_stack (sched, stack, size);
-
- return FALSE;
-}
-
-/**
* gst_scheduler_reset:
* @sched: a #GstScheduler to reset.
*
/* virtual methods */
void (*setup) (GstScheduler *sched);
- gboolean (*get_preferred_stack) (GstScheduler *sched, gpointer *stack, gulong *size);
void (*reset) (GstScheduler *sched);
void (*add_element) (GstScheduler *sched, GstElement *element);
void (*remove_element) (GstScheduler *sched, GstElement *element);
void gst_scheduler_setup (GstScheduler *sched);
-gboolean gst_scheduler_get_preferred_stack(GstScheduler *sched, gpointer *stack, gulong *size);
void gst_scheduler_reset (GstScheduler *sched);
void gst_scheduler_add_element (GstScheduler *sched, GstElement *element);
void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element);
GThread *thread_id; /* id of the thread, if any */
int sched_policy;
int priority;
- gpointer *stack; /* set with gst_scheduler_get_preferred_stack */
+ gpointer *stack;
guint stack_size; /* stack size */
gint pid; /* the pid of the thread */
gint ppid; /* the pid of the thread's parent process */
static void gst_basic_scheduler_dispose (GObject *object);
static void gst_basic_scheduler_setup (GstScheduler *sched);
-static gboolean gst_basic_scheduler_get_preferred_stack (GstScheduler *sched, gpointer *stack, gulong *size);
static void gst_basic_scheduler_reset (GstScheduler *sched);
static void gst_basic_scheduler_add_element (GstScheduler *sched, GstElement *element);
static void gst_basic_scheduler_remove_element (GstScheduler *sched, GstElement *element);
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_basic_scheduler_dispose);
gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_basic_scheduler_setup);
- gstscheduler_class->get_preferred_stack= GST_DEBUG_FUNCPTR (gst_basic_scheduler_get_preferred_stack);
gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_basic_scheduler_reset);
gstscheduler_class->add_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_add_element);
gstscheduler_class->remove_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_remove_element);
}
}
-static gboolean
-gst_basic_scheduler_get_preferred_stack (GstScheduler *sched,
- gpointer *stack, gulong *size)
-{
- if (do_cothreads_stackquery (stack, size)) {
- GST_DEBUG (GST_CAT_SCHEDULING,
- "getting preferred stack size as %p and %lu", *stack, *size);
- return TRUE;
- }
- return FALSE;
-}
-
static void
gst_basic_scheduler_reset (GstScheduler *sched)
{