forked from Imagelibrary/rtems
added some of the required functionality to pthread_setschedparam and
pthread_getschedparam.
This commit is contained in:
@@ -382,13 +382,14 @@ int pthread_getschedparam(
|
|||||||
struct sched_param *param
|
struct sched_param *param
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
pthread_attr_t *attr; /* XXX: really need to get this from the thread */
|
POSIX_API_Control *api;
|
||||||
|
|
||||||
if ( !policy || !param )
|
if ( !policy || !param )
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
*policy = attr->schedpolicy;
|
api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
|
||||||
*param = attr->schedparam;
|
*policy = api->schedpolicy;
|
||||||
|
*param = api->Schedule;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,24 +405,47 @@ int pthread_setschedparam(
|
|||||||
struct sched_param *param
|
struct sched_param *param
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* XXX need to reschedule after doing this to the thread */
|
register Thread_Control *the_thread;
|
||||||
pthread_attr_t *attr; /* XXX: really need to get this from the thread */
|
POSIX_API_Control *api;
|
||||||
|
Objects_Locations location;
|
||||||
|
|
||||||
if ( !param )
|
if ( !param )
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
|
/* XXX need to reschedule after doing this to the thread */
|
||||||
|
/* XXX need to have one routine called by create and here */
|
||||||
|
#warning "pthread_setschedparam needs work"
|
||||||
|
|
||||||
|
the_thread = _POSIX_Threads_Get( thread, &location );
|
||||||
|
switch ( location ) {
|
||||||
|
case OBJECTS_ERROR:
|
||||||
|
case OBJECTS_REMOTE:
|
||||||
|
return ESRCH;
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
switch ( policy ) {
|
switch ( policy ) {
|
||||||
case SCHED_OTHER:
|
case SCHED_OTHER:
|
||||||
case SCHED_FIFO:
|
case SCHED_FIFO:
|
||||||
case SCHED_RR:
|
case SCHED_RR:
|
||||||
case SCHED_SPORADIC:
|
case SCHED_SPORADIC:
|
||||||
attr->schedpolicy = policy;
|
/* XXX this is where the interpretation work should go */
|
||||||
attr->schedparam = *param;
|
break;
|
||||||
return 0;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
|
api->schedpolicy = policy;
|
||||||
|
api->Schedule = *param;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return POSIX_BOTTOM_REACHED();
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -781,8 +805,10 @@ int pthread_join(
|
|||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
if ( api->detachstate == PTHREAD_CREATE_DETACHED )
|
if ( api->detachstate == PTHREAD_CREATE_DETACHED ) {
|
||||||
|
_Thread_Enable_dispatch();
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Put ourself on the threads join list
|
* Put ourself on the threads join list
|
||||||
@@ -822,6 +848,7 @@ int pthread_detach(
|
|||||||
|
|
||||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
api->detachstate = PTHREAD_CREATE_DETACHED;
|
api->detachstate = PTHREAD_CREATE_DETACHED;
|
||||||
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -883,11 +910,18 @@ int pthread_equal(
|
|||||||
pthread_t t2
|
pthread_t t2
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
int status;
|
||||||
Objects_Locations location;
|
Objects_Locations location;
|
||||||
|
|
||||||
/* XXX may want to do a "get" to make sure both are valid. */
|
/* XXX may want to do a "get" to make sure both are valid. */
|
||||||
/* XXX behavior is undefined if not valid pthread_t's */
|
/* XXX behavior is undefined if not valid pthread_t's */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default this is not a match.
|
||||||
|
*/
|
||||||
|
|
||||||
|
status = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validate the first id and return 0 if it is not valid
|
* Validate the first id and return 0 if it is not valid
|
||||||
*/
|
*/
|
||||||
@@ -896,10 +930,9 @@ int pthread_equal(
|
|||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
return 0;
|
|
||||||
case OBJECTS_LOCAL:
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validate the second id and return 0 if it is not valid
|
* Validate the second id and return 0 if it is not valid
|
||||||
@@ -909,11 +942,18 @@ int pthread_equal(
|
|||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
return 0;
|
break;
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
|
status = _Objects_Are_ids_equal( t1, t2 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return _Objects_Are_ids_equal( t1, t2 );
|
_Thread_Unnest_dispatch();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Thread_Enable_dispatch();
|
||||||
|
return status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
|
|||||||
@@ -382,13 +382,14 @@ int pthread_getschedparam(
|
|||||||
struct sched_param *param
|
struct sched_param *param
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
pthread_attr_t *attr; /* XXX: really need to get this from the thread */
|
POSIX_API_Control *api;
|
||||||
|
|
||||||
if ( !policy || !param )
|
if ( !policy || !param )
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
*policy = attr->schedpolicy;
|
api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
|
||||||
*param = attr->schedparam;
|
*policy = api->schedpolicy;
|
||||||
|
*param = api->Schedule;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,24 +405,47 @@ int pthread_setschedparam(
|
|||||||
struct sched_param *param
|
struct sched_param *param
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* XXX need to reschedule after doing this to the thread */
|
register Thread_Control *the_thread;
|
||||||
pthread_attr_t *attr; /* XXX: really need to get this from the thread */
|
POSIX_API_Control *api;
|
||||||
|
Objects_Locations location;
|
||||||
|
|
||||||
if ( !param )
|
if ( !param )
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
|
/* XXX need to reschedule after doing this to the thread */
|
||||||
|
/* XXX need to have one routine called by create and here */
|
||||||
|
#warning "pthread_setschedparam needs work"
|
||||||
|
|
||||||
|
the_thread = _POSIX_Threads_Get( thread, &location );
|
||||||
|
switch ( location ) {
|
||||||
|
case OBJECTS_ERROR:
|
||||||
|
case OBJECTS_REMOTE:
|
||||||
|
return ESRCH;
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
switch ( policy ) {
|
switch ( policy ) {
|
||||||
case SCHED_OTHER:
|
case SCHED_OTHER:
|
||||||
case SCHED_FIFO:
|
case SCHED_FIFO:
|
||||||
case SCHED_RR:
|
case SCHED_RR:
|
||||||
case SCHED_SPORADIC:
|
case SCHED_SPORADIC:
|
||||||
attr->schedpolicy = policy;
|
/* XXX this is where the interpretation work should go */
|
||||||
attr->schedparam = *param;
|
break;
|
||||||
return 0;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
|
api->schedpolicy = policy;
|
||||||
|
api->Schedule = *param;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return POSIX_BOTTOM_REACHED();
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -781,8 +805,10 @@ int pthread_join(
|
|||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
if ( api->detachstate == PTHREAD_CREATE_DETACHED )
|
if ( api->detachstate == PTHREAD_CREATE_DETACHED ) {
|
||||||
|
_Thread_Enable_dispatch();
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Put ourself on the threads join list
|
* Put ourself on the threads join list
|
||||||
@@ -822,6 +848,7 @@ int pthread_detach(
|
|||||||
|
|
||||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
api->detachstate = PTHREAD_CREATE_DETACHED;
|
api->detachstate = PTHREAD_CREATE_DETACHED;
|
||||||
|
_Thread_Enable_dispatch();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -883,11 +910,18 @@ int pthread_equal(
|
|||||||
pthread_t t2
|
pthread_t t2
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
int status;
|
||||||
Objects_Locations location;
|
Objects_Locations location;
|
||||||
|
|
||||||
/* XXX may want to do a "get" to make sure both are valid. */
|
/* XXX may want to do a "get" to make sure both are valid. */
|
||||||
/* XXX behavior is undefined if not valid pthread_t's */
|
/* XXX behavior is undefined if not valid pthread_t's */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default this is not a match.
|
||||||
|
*/
|
||||||
|
|
||||||
|
status = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validate the first id and return 0 if it is not valid
|
* Validate the first id and return 0 if it is not valid
|
||||||
*/
|
*/
|
||||||
@@ -896,10 +930,9 @@ int pthread_equal(
|
|||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
return 0;
|
|
||||||
case OBJECTS_LOCAL:
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validate the second id and return 0 if it is not valid
|
* Validate the second id and return 0 if it is not valid
|
||||||
@@ -909,11 +942,18 @@ int pthread_equal(
|
|||||||
switch ( location ) {
|
switch ( location ) {
|
||||||
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
||||||
case OBJECTS_REMOTE:
|
case OBJECTS_REMOTE:
|
||||||
return 0;
|
break;
|
||||||
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
||||||
|
status = _Objects_Are_ids_equal( t1, t2 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return _Objects_Are_ids_equal( t1, t2 );
|
_Thread_Unnest_dispatch();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Thread_Enable_dispatch();
|
||||||
|
return status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
|
|||||||
Reference in New Issue
Block a user