added some of the required functionality to pthread_setschedparam and

pthread_getschedparam.
This commit is contained in:
Joel Sherrill
1996-06-04 19:44:16 +00:00
parent 3ff4688cdd
commit 230a0dcbb5
2 changed files with 142 additions and 62 deletions

View File

@@ -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;
switch ( policy ) { /* XXX need to reschedule after doing this to the thread */
case SCHED_OTHER: /* XXX need to have one routine called by create and here */
case SCHED_FIFO: #warning "pthread_setschedparam needs work"
case SCHED_RR:
case SCHED_SPORADIC:
attr->schedpolicy = policy;
attr->schedparam = *param;
return 0;
default: the_thread = _POSIX_Threads_Get( thread, &location );
return EINVAL; switch ( location ) {
case OBJECTS_ERROR:
case OBJECTS_REMOTE:
return ESRCH;
case OBJECTS_LOCAL:
switch ( policy ) {
case SCHED_OTHER:
case SCHED_FIFO:
case SCHED_RR:
case SCHED_SPORADIC:
/* XXX this is where the interpretation work should go */
break;
default:
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
) )
{ {
Objects_Locations location; int status;
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,24 +930,30 @@ 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:
/*
* Validate the second id and return 0 if it is not valid
*/
(void) _POSIX_Threads_Get( t2, &location );
switch ( location ) {
case OBJECTS_ERROR:
case OBJECTS_REMOTE:
break;
case OBJECTS_LOCAL:
status = _Objects_Are_ids_equal( t1, t2 );
break;
}
_Thread_Unnest_dispatch();
break; break;
} }
/* _Thread_Enable_dispatch();
* Validate the second id and return 0 if it is not valid return status;
*/
(void) _POSIX_Threads_Get( t2, &location );
switch ( location ) {
case OBJECTS_ERROR:
case OBJECTS_REMOTE:
return 0;
case OBJECTS_LOCAL:
break;
}
return _Objects_Are_ids_equal( t1, t2 );
} }
/*PAGE /*PAGE

View File

@@ -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;
switch ( policy ) { /* XXX need to reschedule after doing this to the thread */
case SCHED_OTHER: /* XXX need to have one routine called by create and here */
case SCHED_FIFO: #warning "pthread_setschedparam needs work"
case SCHED_RR:
case SCHED_SPORADIC:
attr->schedpolicy = policy;
attr->schedparam = *param;
return 0;
default: the_thread = _POSIX_Threads_Get( thread, &location );
return EINVAL; switch ( location ) {
case OBJECTS_ERROR:
case OBJECTS_REMOTE:
return ESRCH;
case OBJECTS_LOCAL:
switch ( policy ) {
case SCHED_OTHER:
case SCHED_FIFO:
case SCHED_RR:
case SCHED_SPORADIC:
/* XXX this is where the interpretation work should go */
break;
default:
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
) )
{ {
Objects_Locations location; int status;
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,24 +930,30 @@ 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:
/*
* Validate the second id and return 0 if it is not valid
*/
(void) _POSIX_Threads_Get( t2, &location );
switch ( location ) {
case OBJECTS_ERROR:
case OBJECTS_REMOTE:
break;
case OBJECTS_LOCAL:
status = _Objects_Are_ids_equal( t1, t2 );
break;
}
_Thread_Unnest_dispatch();
break; break;
} }
/* _Thread_Enable_dispatch();
* Validate the second id and return 0 if it is not valid return status;
*/
(void) _POSIX_Threads_Get( t2, &location );
switch ( location ) {
case OBJECTS_ERROR:
case OBJECTS_REMOTE:
return 0;
case OBJECTS_LOCAL:
break;
}
return _Objects_Are_ids_equal( t1, t2 );
} }
/*PAGE /*PAGE