mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
ok, this seems to be the right fix for the basic scheduler.
Original commit message from CVS: ok, this seems to be the right fix for the basic scheduler. I'd appreciate it if : a) someone looks over these minimal changes and tells me if they're done in the right way (especially the alignment argument ;)) b) others run lots of pipes with basic and tell me if they still have issues If all goes well I want to revert to the basic scheduler and do a release
This commit is contained in:
parent
f4046ced1c
commit
b7bc06aee5
3 changed files with 39 additions and 3 deletions
|
@ -179,11 +179,18 @@ cothread_create (cothread_context *ctx)
|
||||||
stack_end = (guchar *) ((gulong) sp & ~(STACK_SIZE - 1));
|
stack_end = (guchar *) ((gulong) sp & ~(STACK_SIZE - 1));
|
||||||
|
|
||||||
thread = (cothread_state *) (stack_end + ((slot - 1) * COTHREAD_STACKSIZE));
|
thread = (cothread_state *) (stack_end + ((slot - 1) * COTHREAD_STACKSIZE));
|
||||||
GST_DEBUG (GST_CAT_COTHREADS, "new stack at %p", thread);
|
GST_DEBUG (GST_CAT_COTHREADS,
|
||||||
|
"new cothread slot stack from %p to %p (size %ld)",
|
||||||
|
thread, thread + COTHREAD_STACKSIZE - 1,
|
||||||
|
(long) COTHREAD_STACKSIZE);
|
||||||
|
|
||||||
GST_DEBUG (GST_CAT_COTHREADS, "going into mmap");
|
GST_DEBUG (GST_CAT_COTHREADS, "going into mmap");
|
||||||
|
/* the mmap is used to reserve part of the stack
|
||||||
|
* ie. we state explicitly that we are going to use it */
|
||||||
|
munmap ((void *) thread, COTHREAD_STACKSIZE);
|
||||||
mmaped = mmap ((void *) thread, COTHREAD_STACKSIZE,
|
mmaped = mmap ((void *) thread, COTHREAD_STACKSIZE,
|
||||||
PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||||
|
MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||||
GST_DEBUG (GST_CAT_COTHREADS, "coming out of mmap");
|
GST_DEBUG (GST_CAT_COTHREADS, "coming out of mmap");
|
||||||
if (mmaped == MAP_FAILED) {
|
if (mmaped == MAP_FAILED) {
|
||||||
perror ("mmap'ing cothread stack space");
|
perror ("mmap'ing cothread stack space");
|
||||||
|
@ -446,6 +453,34 @@ cothread_context_get_data (cothread_state * thread, gchar * key)
|
||||||
return g_hash_table_lookup (ctx->data, key);
|
return g_hash_table_lookup (ctx->data, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
/* wingo: use posix_memalign to allocate a 2M-aligned, 2M stack */
|
||||||
|
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
|
retval = posix_memalign (stack, STACK_SIZE, STACK_SIZE);
|
||||||
|
if (retval != 0)
|
||||||
|
{
|
||||||
|
g_warning ("Could not posix_memalign stack !\n");
|
||||||
|
*stacksize = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
GST_DEBUG (GST_CAT_COTHREADS,
|
||||||
|
"Got new cothread stack from %p to %p (size %ld)\n",
|
||||||
|
*stack, *stack + STACK_SIZE - 1, (long) STACK_SIZE);
|
||||||
|
*stacksize = STACK_SIZE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cothread_switch:
|
* cothread_switch:
|
||||||
* @thread: cothread state to switch to
|
* @thread: cothread state to switch to
|
||||||
|
|
|
@ -81,6 +81,7 @@ void cothread_setfunc (cothread_state *thread, cothread_func func,
|
||||||
void cothread_stop (cothread_state *thread);
|
void cothread_stop (cothread_state *thread);
|
||||||
|
|
||||||
void cothread_switch (cothread_state *thread);
|
void cothread_switch (cothread_state *thread);
|
||||||
|
gboolean cothread_stackquery (void **stack, glong* stacksize);
|
||||||
void cothread_set_private (cothread_state *thread,
|
void cothread_set_private (cothread_state *thread,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
gpointer cothread_get_private (cothread_state *thread);
|
gpointer cothread_get_private (cothread_state *thread);
|
||||||
|
|
|
@ -40,7 +40,7 @@ typedef cothread_state cothread;
|
||||||
*/
|
*/
|
||||||
#define do_cothreads_init(x) /* NOP */
|
#define do_cothreads_init(x) /* NOP */
|
||||||
|
|
||||||
#define do_cothreads_stackquery(stack,size) FALSE
|
#define do_cothreads_stackquery(stack,size) cothread_stackquery(stack,size)
|
||||||
|
|
||||||
#define do_cothread_switch(to) cothread_switch(to)
|
#define do_cothread_switch(to) cothread_switch(to)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue