summaryrefslogtreecommitdiffstats
path: root/c/src/exec/posix/src/pthread.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-04 19:44:16 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-04 19:44:16 +0000
commit230a0dcbb5845ecd56035aa02df5e837f7d59683 (patch)
treef0a3a47568bd19761fed082ec27e55286124da4c /c/src/exec/posix/src/pthread.c
parentclean up pass (diff)
downloadrtems-230a0dcbb5845ecd56035aa02df5e837f7d59683.tar.bz2
added some of the required functionality to pthread_setschedparam and
pthread_getschedparam.
Diffstat (limited to 'c/src/exec/posix/src/pthread.c')
-rw-r--r--c/src/exec/posix/src/pthread.c102
1 files changed, 71 insertions, 31 deletions
diff --git a/c/src/exec/posix/src/pthread.c b/c/src/exec/posix/src/pthread.c
index 37df7c5080..3f6b8f8991 100644
--- a/c/src/exec/posix/src/pthread.c
+++ b/c/src/exec/posix/src/pthread.c
@@ -382,13 +382,14 @@ int pthread_getschedparam(
struct sched_param *param
)
{
- pthread_attr_t *attr; /* XXX: really need to get this from the thread */
+ POSIX_API_Control *api;
if ( !policy || !param )
return EINVAL;
- *policy = attr->schedpolicy;
- *param = attr->schedparam;
+ api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
+ *policy = api->schedpolicy;
+ *param = api->Schedule;
return 0;
}
@@ -404,24 +405,47 @@ int pthread_setschedparam(
struct sched_param *param
)
{
- /* XXX need to reschedule after doing this to the thread */
- pthread_attr_t *attr; /* XXX: really need to get this from the thread */
-
+ register Thread_Control *the_thread;
+ POSIX_API_Control *api;
+ Objects_Locations location;
+
if ( !param )
return EINVAL;
- switch ( policy ) {
- case SCHED_OTHER:
- case SCHED_FIFO:
- case SCHED_RR:
- case SCHED_SPORADIC:
- attr->schedpolicy = policy;
- attr->schedparam = *param;
- return 0;
+ /* 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 ) {
+ 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;
+ 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
@@ -781,8 +805,10 @@ int pthread_join(
case OBJECTS_LOCAL:
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;
+ }
/*
* Put ourself on the threads join list
@@ -822,6 +848,7 @@ int pthread_detach(
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
api->detachstate = PTHREAD_CREATE_DETACHED;
+ _Thread_Enable_dispatch();
return 0;
}
@@ -883,37 +910,50 @@ int pthread_equal(
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 behavior is undefined if not valid pthread_t's */
/*
- * Validate the first id and return 0 if it is not valid
+ * By default this is not a match.
*/
- (void) _POSIX_Threads_Get( t1, &location );
- switch ( location ) {
- case OBJECTS_ERROR:
- case OBJECTS_REMOTE:
- return 0;
- case OBJECTS_LOCAL:
- break;
- }
+ status = 0;
/*
- * Validate the second id and return 0 if it is not valid
+ * Validate the first id and return 0 if it is not valid
*/
- (void) _POSIX_Threads_Get( t2, &location );
+ (void) _POSIX_Threads_Get( t1, &location );
switch ( location ) {
case OBJECTS_ERROR:
case OBJECTS_REMOTE:
- return 0;
+ break;
+
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;
}
- return _Objects_Are_ids_equal( t1, t2 );
+
+ _Thread_Enable_dispatch();
+ return status;
+
}
/*PAGE