Release 6.2.0

This commit is contained in:
Tiejun Zhou
2022-10-26 23:41:13 +00:00
parent b871c33620
commit 3e8e85cdc1
173 changed files with 26264 additions and 3989 deletions

View File

@@ -22,7 +22,10 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 09-30-2020 William E. Lamie Initial Version 6.1 */
/* 09-30-2020 William E. Lamie Initial Version 6.1 */
/* 10-31-2022 Scott Larson Change configSTACK_DEPTH_TYPE */
/* to 32 bit instead of 16 bit, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -52,7 +55,7 @@
/* #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 */
/* #define configMESSAGE_BUFFER_LENGTH_TYPE size_t */
#define configSTACK_DEPTH_TYPE uint16_t
#define configSTACK_DEPTH_TYPE uint32_t
/* #define configUSE_CO_ROUTINES 0 */
/* #define configMAX_CO_ROUTINE_PRIORITIES (2) */

View File

@@ -24,7 +24,7 @@
/* EKP DEFINITIONS RELEASE */
/* */
/* px_int.h PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -39,7 +39,9 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Remove unneeded values, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -52,14 +54,9 @@
#define TX_INITIALIZE_IN_PROGRESS 0xF0F0F0F0UL
#define TX_INITIALIZE_ALMOST_DONE 0xF0F0F0F1UL
/* Include necessary definition for memory related routines(from tx_byt.c). */
#define TX_BYTE_BLOCK_FREE 0xFFFFEEEEUL
#define TX_BYTE_BLOCK_ALLOC 0xAAAAAAAAUL
#define TX_BYTE_POOL_ID 0x42595445UL
/* Threadx min and max priority */
#define TX_HIGHEST_PRIORITY 1
#define TX_LOWEST_PRIORITY 31
#define TX_LOWEST_PRIORITY 31
#define PX_HIGHEST_PRIORITY 31
#define PX_LOWEST_PRIORITY 1
@@ -194,7 +191,7 @@ VOID posix_thread_wrapper(ULONG pthr_ptr);
VOID set_default_pthread_attr(pthread_attr_t *attr);
VOID set_default_mutexattr(pthread_mutexattr_t *attr);
VOID set_default_mutexattr(pthread_mutexattr_t *attr);
INT posix_allocate_pthread_t(POSIX_TCB **ptcb_ptr);

View File

@@ -12,8 +12,8 @@
/**************************************************************************/
/**************************************************************************/
/** */
/** POSIX wrapper for THREADX */
/** */
/** POSIX wrapper for THREADX */
/** */
/** */
/** */
@@ -32,14 +32,14 @@
/* FUNCTION RELEASE */
/* */
/* posix_arrange_msg PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* arrange messages from the queue */
/* Return the oldest, highest priority message from the queue. */
/* */
/* INPUT */
/* */
@@ -62,117 +62,128 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Modified comments, */
/* fixed message swap logic, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
ULONG posix_arrange_msg( TX_QUEUE *Queue, ULONG *pMsgPrio )
ULONG posix_arrange_msg(TX_QUEUE *Queue, ULONG *pMsgPrio)
{
ULONG* Qread; /* to store read ptr of the queue */
ULONG* temp_q = TX_NULL; /* temp storage for the message pointer */
ULONG numMsgs; /* no of messages queued */
ULONG msg; /* temp variable for thr for loop */
ULONG priority; /* priority of the message */
ULONG maxPrio; /* max. priority of the messages in queue*/
ULONG number2; /* messages */
ULONG minNo; /* oldest message in the same priority */
ULONG swap; /* temp.variable for the swapping of the */
/* messages */
ULONG* q_read; /* to store read ptr of the queue */
ULONG* temp_q = TX_NULL; /* temp storage for the message pointer */
ULONG numMsgs; /* no of messages queued */
ULONG msg; /* temp variable for thr for loop */
ULONG priority; /* priority of the message */
ULONG maxPrio; /* max. priority of the messages in queue*/
ULONG number2; /* messages */
ULONG minNo; /* oldest message in the same priority */
ULONG swap; /* temp.variable for the swapping of the */
/* messages */
/* initialize the priority to the lowest priority. */
maxPrio = 0;
minNo=0;
minNo = 0;
/* Copy read pointer to the temporary variable. */
Qread = Queue -> tx_queue_read;
q_read = Queue -> tx_queue_read;
/* Copy no. of messages in the queue to the temporary variable. */
numMsgs = Queue -> tx_queue_enqueued;
if( numMsgs == 0 )
return(OK);
for( msg = 0; msg < numMsgs; msg ++)
/* If there is 0 or 1 message, no rearranging is needed. */
if (numMsgs < 2)
{
return(OK);
}
/* Advance Qread by two pointers to read the priority of the message. */
Qread = Qread + 2 ;
for (msg = 0; msg < numMsgs; msg++)
{
/* Advance q_read to read the priority of the message. */
q_read = q_read + TX_POSIX_QUEUE_PRIORITY_OFFSET;
/* Priority of the message queued. */
priority = *Qread;
priority = *q_read;
/* check with maxpriority. */
if( priority > maxPrio )
{
/* copy read pointer to temporary buffer. */
temp_q = Qread-2;
if (priority > maxPrio)
{
/* copy read pointer to temporary pointer. */
temp_q = q_read-TX_POSIX_QUEUE_PRIORITY_OFFSET;
/* increment read pointer to point to order. */
Qread++;
q_read++;
/* copy FIFO order to the message */
minNo = *Qread;
minNo = *q_read;
/* Found higher priority message. */
maxPrio = priority;
Qread++;
q_read++;
}
/* if more than one same priority messages are in the queue
then check if this the oldest one. */
else if ( priority == maxPrio )
/* if more than one message of the same priority is in the queue
then check if this the oldest message. */
else if (priority == maxPrio)
{
/* increment read pointer to point to read FIFO order */
Qread++;
q_read++;
/* copy number to the local varialble. */
number2 = *Qread;
Qread++;
/* find the oldest of the messages in this priority level. */
if( number2 < minNo )
{
/* founder older one */
minNo = number2;
/* copy read pointer to temporary buffer. */
temp_q = Qread - 4;
}
/* copy number to the local variable. */
number2 = *q_read;
/* Go to next message. */
q_read++;
/* find the oldest of the messages in this priority level. */
if( number2 < minNo )
{
/* founder older one */
minNo = number2;
/* copy read pointer to temporary buffer. */
temp_q = q_read - (TX_POSIX_MESSAGE_SIZE);
}
}
else
Qread = Qread + 2;
else
{
/* Not highest priority, go to next message. */
q_read = q_read + (TX_POSIX_MESSAGE_SIZE - TX_POSIX_QUEUE_PRIORITY_OFFSET);
}
/* Determine if we are at the end. */
if ( Qread >= Queue ->tx_queue_end)
/* Yes, wrap around to the beginning. */
Qread = Queue -> tx_queue_start;
/* Determine if we are at the end. */
if (q_read >= Queue -> tx_queue_end)
{
/* Yes, wrap around to the beginning. */
q_read = Queue -> tx_queue_start;
}
}
/* All messages checked temp holds address of highest priority message and
maxPrio holds the highest priority*/
if( pMsgPrio != NULL )
/* Output priority if non-null */
if (pMsgPrio != NULL)
{
/* copy message priority. */
*pMsgPrio = maxPrio;
}
/* All messages checked, temp_q holds address of oldest highest priority message
and maxPrio holds the highest priority. */
/* Get the current queue read pointer */
Qread = Queue -> tx_queue_read;
/* if(*pMsgPrio != *(Qread + 2) || minNo < *(Qread + 3))*/
q_read = Queue -> tx_queue_read;
if((temp_q != TX_NULL) && (temp_q != q_read))
{
/* Swap the messages. */
for ( msg = 0; msg < 4; msg++)
for (msg = 0; msg < TX_POSIX_MESSAGE_SIZE; msg++)
{
swap = *temp_q;
*temp_q = *Qread;
*Qread = swap;
*temp_q = *q_read;
*q_read = swap;
temp_q++;
Qread++;
q_read++;
}
}
return(OK);
}

View File

@@ -26,13 +26,12 @@
#include "pthread.h" /* Posix API */
#include "px_int.h" /* Posix helper functions */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* posix_mq_create PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -74,7 +73,9 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Add 64-bit support, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
POSIX_MSG_QUEUE * posix_mq_create (const CHAR * mq_name,
@@ -125,9 +126,9 @@ TX_QUEUE *TheQ;
to store only the message pointer and message length. */
temp1 = tx_queue_create((&(posix_q->queue)),
(CHAR *)mq_name,
TX_4_ULONG,
TX_POSIX_MESSAGE_SIZE,
posix_q->storage,
(msgq_attr->mq_maxmsg * 16));
(msgq_attr->mq_maxmsg * (sizeof(ULONG) * TX_POSIX_MESSAGE_SIZE)));
/* Make sure it worked. */
if (temp1 != TX_SUCCESS)

View File

@@ -32,7 +32,7 @@
/* FUNCTION RELEASE */
/* */
/* mq_open PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -68,7 +68,9 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Update comparison with NULL, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
mqd_t mq_open(const CHAR * mqName, ULONG oflags,...)
@@ -115,7 +117,7 @@ ULONG temp1;
}
/* Check if name is exist. NULL if successful. */
if(posix_queue = posix_find_queue(mqName))
if((posix_queue = posix_find_queue(mqName)) != NULL)
{
if(posix_queue->unlink_flag == TX_TRUE)
{
@@ -172,7 +174,7 @@ ULONG temp1;
case O_RDWR:
case O_NONBLOCK:
/* Check if name is exist. NULL if successful. */
if(posix_queue = posix_find_queue(mqName))
if((posix_queue = posix_find_queue(mqName)) != NULL)
{
if(posix_queue->unlink_flag == TX_TRUE)
{

View File

@@ -12,8 +12,8 @@
/**************************************************************************/
/**************************************************************************/
/** */
/** POSIX wrapper for THREADX */
/** */
/** POSIX wrapper for THREADX */
/** */
/** */
/** */
@@ -32,7 +32,7 @@
/* FUNCTION RELEASE */
/* */
/* posix_priority_search PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -63,15 +63,17 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Add 64-bit support, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
ULONG posix_priority_search(mqd_t msgQId ,ULONG priority)
ULONG posix_priority_search(mqd_t msgQId, ULONG priority)
{
TX_QUEUE *queue;
POSIX_MSG_QUEUE *q_ptr;
ULONG order;
ULONG order = 1;
ULONG numMsgs;
UINT index;
ULONG *source;
@@ -87,18 +89,21 @@ ULONG msgp;
source = q_ptr->queue.tx_queue_read;
/* check for same priority. */
for(index = 0,order = 1;index <= numMsgs ;index++)
for(index = 0; index < numMsgs; index++)
{
source += 2;
source += TX_POSIX_QUEUE_PRIORITY_OFFSET;
msgp = *source;
source += 2;
source += (TX_POSIX_MESSAGE_SIZE - TX_POSIX_QUEUE_PRIORITY_OFFSET);
/* If we're at end of queue, go to start. */
if(source == q_ptr->queue.tx_queue_end)
source = q_ptr->queue.tx_queue_start;
/* Increment priority count. */
if(priority == msgp)
order += 1;
}
/* Returns the number of same priority messages. */
/* Return the number of same priority messages. */
return(order);
}

View File

@@ -32,7 +32,7 @@
/* FUNCTION RELEASE */
/* */
/* mq_receive PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -71,7 +71,9 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Add 64-bit support, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
ssize_t mq_receive( mqd_t mqdes, VOID * pMsg, size_t msgLen, ULONG *pMsgPrio)
@@ -141,7 +143,7 @@ VOID * message_source;
/* Try to get a message from the message queue. */
/* Create a temporary buffer to get message pointer and message length. */
temp1 = posix_memory_allocate((sizeof(ULONG)) * 4 , (VOID**)&msgbuf1);
temp1 = posix_memory_allocate((sizeof(ULONG)) * TX_POSIX_MESSAGE_SIZE, (VOID**)&msgbuf1);
if(temp1 != TX_SUCCESS )
{
/* Return generic error. */
@@ -212,11 +214,18 @@ VOID * message_source;
my_ptr = ( ULONG *)msgbuf1;
/* Retrieve Message pointer, message Length and message priority. */
#ifdef TX_64_BIT
this_ptr = (CHAR *)((((ALIGN_TYPE)my_ptr[0]) << 32) | my_ptr[1]);
length_of_message = my_ptr[2];
priority_of_message = my_ptr[3];
#else
this_ptr = (CHAR *)(*my_ptr);
message_source = (VOID *)this_ptr;
length_of_message = *(++my_ptr);
priority_of_message = *(++my_ptr);
#endif
message_source = (VOID *)this_ptr;
/* Copy message into supplied buffer. */
msgbuf2 = (UCHAR *)pMsg;

View File

@@ -26,7 +26,6 @@
#include "pthread.h" /* Posix API */
#include "px_int.h" /* Posix helper functions */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
@@ -73,7 +72,9 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Add 64-bit support, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
INT mq_send( mqd_t mqdes, const CHAR * msg_ptr, size_t msg_len,
@@ -88,7 +89,7 @@ UCHAR *source;
UCHAR *destination;
UCHAR *save_ptr;
ULONG mycount;
ULONG msg[4];
ULONG msg[TX_POSIX_MESSAGE_SIZE];
/* Assign a temporary variable for clarity. */
Queue = &(mqdes->f_data->queue);
@@ -99,7 +100,7 @@ ULONG msg[4];
{
/* Queue pointer is invalid, return appropriate error code. */
posix_errno = EBADF;
posix_set_pthread_errno(EBADF);
posix_set_pthread_errno(EBADF);
/* Return ERROR. */
return(ERROR);
@@ -110,7 +111,7 @@ ULONG msg[4];
{
/* POSIX doesn't have error for this, hence give default. */
posix_errno = EINTR ;
posix_set_pthread_errno(EINTR);
posix_set_pthread_errno(EINTR);
/* Return ERROR. */
return(ERROR);
@@ -121,7 +122,7 @@ ULONG msg[4];
{
/* Queue descriptor is invalid, set appropriate error code. */
posix_errno = EBADF ;
posix_set_pthread_errno(EBADF);
posix_set_pthread_errno(EBADF);
/* Return ERROR. */
return(ERROR);
@@ -130,7 +131,7 @@ ULONG msg[4];
{
/* Queue pointer is invalid, return appropriate error code. */
posix_errno = EBADF;
posix_set_pthread_errno(EBADF);
posix_set_pthread_errno(EBADF);
/* Return ERROR. */
return(ERROR);
@@ -139,7 +140,7 @@ ULONG msg[4];
{
/* Return appropriate error. */
posix_errno = EINVAL;
posix_set_pthread_errno(EINVAL);
posix_set_pthread_errno(EINVAL);
/* Return error. */
return(ERROR);
@@ -149,7 +150,7 @@ ULONG msg[4];
{
/* POSIX doesn't have error for this, hence give default. */
posix_errno = EINTR ;
posix_set_pthread_errno(EINTR);
posix_set_pthread_errno(EINTR);
/* Return ERROR. */
return(ERROR);
@@ -160,7 +161,7 @@ ULONG msg[4];
{
/* Return message length exceeds max length. */
posix_errno = EMSGSIZE ;
posix_set_pthread_errno(EMSGSIZE);
posix_set_pthread_errno(EMSGSIZE);
/* Return ERROR. */
return(ERROR);
@@ -192,11 +193,18 @@ ULONG msg[4];
/* Restore the pointer of save message. */
source = save_ptr ;
/* Create message that holds saved message pointer and message length. */
#ifdef TX_64_BIT
msg[0] = (ULONG)((ALIGN_TYPE)source >> 32);
msg[1] = (ULONG)((ALIGN_TYPE)source);
msg[2] = msg_len;
msg[3] = msg_prio;
msg[4] = posix_priority_search(mqdes, msg_prio);
#else
msg[0] = (ULONG)source;
msg[1] = msg_len;
msg[2] = msg_prio;
msg[3] = posix_priority_search(mqdes, msg_prio);
#endif
/* Attempt to post the message to the queue. */
temp1 = tx_queue_send(Queue, msg, TX_WAIT_FOREVER);
if ( temp1 != TX_SUCCESS)

View File

@@ -12,40 +12,38 @@
/**************************************************************************/
/**************************************************************************/
/** */
/** POSIX wrapper for THREADX */
/** */
/** */
/** POSIX wrapper for THREADX */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#include "tx_api.h" /* Threadx API */
#include "pthread.h" /* Posix API */
#include "px_int.h" /* Posix helper functions */
#include "tx_api.h" /* Threadx API */
#include "pthread.h" /* Posix API */
#include "px_int.h" /* Posix helper functions */
#include <limits.h>
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* nanosleep PORTABLE C */
/* 6.1.7 */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* nanosleep PORTABLE C */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* DESCRIPTION */
/* */
/* This function shall cause the current thread to be suspended from */
/* execution until the time interval specified by the req argument has */
/* elapsed */
/* elapsed. */
/* */
/* INPUT */
/* INPUT */
/* */
/* req Is the number of real-time (as opposed */
/* req The number of real-time (as opposed */
/* to CPU-time) seconds and nanoseconds to */
/* suspend the calling thread. */
/* rem Points to a structure to receive the */
@@ -53,61 +51,62 @@
/* interrupted by a signal. This pointer */
/* may be NULL. */
/* */
/* OUTPUT */
/* */
/* OUTPUT */
/* */
/* zero If the function returns because the */
/* requested time has elapsed. */
/* */
/* -1 If this functions fails if req argument */
/* specified a value less than zero or */
/* greater than or equal to 1 000 million. */
/* specified a nanosecond value greater */
/* than or equal to 1 billion. */
/* */
/* */
/* CALLS */
/* CALLS */
/* */
/* tx_thread_sleep ThreadX thread sleep service */
/* */
/* CALLED BY */
/* */
/* Application Code */
/* */
/* RELEASE HISTORY */
/* */
/* CALLED BY */
/* */
/* Application Code */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Fix bounds check, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
INT nanosleep(struct timespec *req, struct timespec *rem)
{
ULONG timer_ticks;
/* Check for valid inputs */
/* The nanosecond value must be greater than zero or less than 1 000 million. */
if ( (!req) || ((req->tv_nsec) <= 0) || (req->tv_nsec > 999999999 )) /* 08-11-2005 */
/* Check for valid inputs - the nanosecond value must be less than 1 billion
and not roll over when converting to ThreadX timer ticks. */
if ( (!req) || (req->tv_nsec > 999999999) || ((timer_ticks = (req->tv_sec * CPU_TICKS_PER_SECOND + req->tv_nsec/NANOSECONDS_IN_CPU_TICK)) < req->tv_sec) )
{
posix_errno = EINVAL;
posix_set_pthread_errno(EINVAL);
return(ERROR);
}
/* Convert sleep time into Clock ticks */
/* Also add some padding so that the thread will sleep no less than the
specified time */
timer_ticks = (ULONG) ( ( req->tv_sec * CPU_TICKS_PER_SECOND ) + ( req->tv_nsec/ NANOSECONDS_IN_CPU_TICK) + 1 ); /* 08-11-2005 */
/* Now call ThreadX thread sleep service */
/* Add padding of 1 so that the thread will sleep no less than the specified time,
except in the case that timer_ticks is ULONG_MAX */
if(timer_ticks != ULONG_MAX)
{
timer_ticks = timer_ticks + 1;
}
/* Now call ThreadX thread sleep service. */
tx_thread_sleep(timer_ticks);
/* Sleep completed */
if ( rem ) /* 08-11-2005 */
/* Sleep completed. */
if (rem)
{
rem->tv_nsec = 0;
rem->tv_sec = 0; /* 08-11-2005 */
}
rem->tv_nsec = 0;
rem->tv_sec = 0;
}
return(OK);
}

View File

@@ -32,7 +32,7 @@
/* FUNCTION RELEASE */
/* */
/* pthread_create PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -98,7 +98,10 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Add 64-bit support, */
/* remove double parenthesis, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
INT pthread_create (pthread_t *thread, pthread_attr_t *attr,
@@ -211,7 +214,7 @@ INT status,retval;
status = posix_memory_allocate( pthread_ptr->stack_size, &(pthread_ptr->stack_address));
/* problem allocating stack space */
if ((status == ERROR))
if (status == ERROR)
{
/* Configuration/resource error. */
return(EAGAIN);
@@ -227,17 +230,19 @@ INT status,retval;
/* Now actually create and start the thread. */
/* convert Posix priorities to Threadx priority */
retval += tx_thread_create( thread_ptr,
retval += tx_thread_create(thread_ptr,
"pthr",
posix_thread_wrapper,
(ULONG)pthread_ptr,
(ULONG)(ALIGN_TYPE)pthread_ptr,
pthread_ptr->stack_address,
pthread_ptr->stack_size,
(TX_LOWEST_PRIORITY - pthread_ptr->current_priority + 1),
(TX_LOWEST_PRIORITY - pthread_ptr->threshold + 1),
pthread_ptr->time_slice,
TX_AUTO_START);
TX_THREAD_EXTENSION_PTR_SET(thread_ptr, pthread_ptr)
/* See if ThreadX encountered an error */
if (retval)
{

View File

@@ -318,7 +318,7 @@ ULONG index;
/* FUNCTION RELEASE */
/* */
/* posix_thread_wrapper PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -352,7 +352,9 @@ ULONG index;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Add 64-bit support, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID posix_thread_wrapper(ULONG pthr_ptr)
@@ -362,7 +364,8 @@ POSIX_TCB *pthread_ptr;
VOID *value_ptr;
/* The input argument is really a pointer to the pthread's control block */
pthread_ptr = (POSIX_TCB *) pthr_ptr;
TX_THREAD_EXTENSION_PTR_GET(pthread_ptr, POSIX_TCB, pthr_ptr)
/* Invoke the pthread start routine with appropriate arguments */
value_ptr = (pthread_ptr->start_routine)((VOID *)pthread_ptr->entry_parameter);
@@ -668,7 +671,7 @@ POSIX_TCB *pthread;
/* FUNCTION RELEASE */
/* */
/* posix_destroy_pthread PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -701,19 +704,28 @@ POSIX_TCB *pthread;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Add 64-bit support, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID posix_destroy_pthread(POSIX_TCB *pthread_ptr, VOID *value_ptr)
{
ULONG request[WORK_REQ_SIZE];
INT status;
ULONG request[WORK_REQ_SIZE];
UINT status;
/* Build the request. */
request[0] = (ULONG)pthread_ptr;
#ifdef TX_64_BIT
request[0] = (ULONG)((ALIGN_TYPE)pthread_ptr >> 32);
request[1] = (ULONG)((ALIGN_TYPE)pthread_ptr);
request[2] = (ULONG)((ALIGN_TYPE)value_ptr >> 32);
request[3] = (ULONG)((ALIGN_TYPE)value_ptr);
#else
request[0] = (ULONG)pthread_ptr;
request[1] = (ULONG)value_ptr;
#endif
/* Send a message to the SysMgr supervisor thread, asking it to delete */
/* the pthread. Since the SysMgr supervisor thread is the highest */

View File

@@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* pthread_kill PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -73,11 +73,13 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Remove double parenthesis, */
/* update argument type, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
int pthread_kill(ULONG thread_id, int sig)
int pthread_kill(ALIGN_TYPE thread_id, int sig)
{
TX_INTERRUPT_SAVE_AREA
@@ -197,7 +199,7 @@ UINT retval;
status = posix_memory_allocate(new_signal_thread -> stack_size, &new_signal_thread -> stack_address);
/* problem allocating stack space */
if ((status == ERROR))
if (status == ERROR)
{
/* Mark the previously allocated control block as available. */

View File

@@ -32,7 +32,7 @@
/* FUNCTION RELEASE */
/* */
/* pthread_sigmask PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -68,7 +68,10 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Update pthread_kill argument */
/* cast, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -188,7 +191,7 @@ ULONG reissue_flag;
base_thread -> signals.signal_pending.signal_set = base_thread -> signals.signal_pending.signal_set & ~(((unsigned long) 1) << signal_number);
/* Call pthread_kill to reissue the signal. */
pthread_kill((ULONG) base_thread, signal_number);
pthread_kill((ALIGN_TYPE) base_thread, signal_number);
/* Set the reissue flag. */
reissue_flag = TX_TRUE;

View File

@@ -32,7 +32,7 @@
/* FUNCTION RELEASE */
/* */
/* sem_open PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -69,7 +69,9 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Update comparison with NULL, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
sem_t * sem_open(const CHAR * name, ULONG oflag, ...)
@@ -110,7 +112,7 @@ mode_t mode;
}
/* Check if semaphore exists. */
if(semid= posix_find_sem( name))
if((semid = posix_find_sem(name)) != NULL)
{
if(semid->unlink_flag ==TX_TRUE )
{

View File

@@ -32,7 +32,7 @@
/* FUNCTION RELEASE */
/* */
/* sem_unlink PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -65,7 +65,9 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Remove double parenthesis, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
INT sem_unlink(const CHAR * name)
@@ -102,7 +104,7 @@ ULONG len;
sem->unlink_flag =TX_TRUE;
/* Check for the count. */
if ((sem->count == 0) )
if(sem->count == 0)
{
posix_sem_reset(sem );
sem = NULL;

View File

@@ -31,7 +31,7 @@
/* FUNCTION RELEASE */
/* */
/* posix_system_manager_entry PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -63,7 +63,9 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Add 64-bit support, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID posix_system_manager_entry(ULONG input)
@@ -72,25 +74,35 @@ VOID posix_system_manager_entry(ULONG input)
UINT status;
ULONG request[WORK_REQ_SIZE];
/* Avoid compiler warning. */
if (input) { }
POSIX_TCB *pthread_ptr;
VOID *value_ptr;
/* Avoid compiler warning. */
TX_PARAMETER_NOT_USED(input);
/* Loop forever, waiting for work requests. */
while(1)
{
/* Wait forever for the next work request. */
/* Wait forever for the next work request. */
status = tx_queue_receive(&posix_work_queue, &request, TX_WAIT_FOREVER);
/* Make sure we didn't encounter any trouble. */
if (status != TX_SUCCESS)
{
/* Hmmmm... should not happen. */
/* Anywayjust go back and get the next message. */
continue;
/* Get the next message. */
continue;
}
/* Go delete the pthread */
posix_do_pthread_delete((POSIX_TCB *)request[0], (VOID *)request[1] );
} /* System Manager forever loop */
#ifdef TX_64_BIT
pthread_ptr = (POSIX_TCB *)((((ALIGN_TYPE)request[0]) << 32) | request[1]);
value_ptr = (VOID *)((((ALIGN_TYPE)request[2]) << 32) | request[3]);
#else
pthread_ptr = (POSIX_TCB *)request[0];
value_ptr = (VOID *)request[1];
#endif
/* Delete the pthread */
posix_do_pthread_delete(pthread_ptr, value_ptr);
} /* System Manager forever loop */
}

View File

@@ -173,7 +173,7 @@ INT sched_get_priority_min(INT policy)
INT pthread_once (pthread_once_t * once_control, VOID (*init_routine) (VOID))
INT pthread_kill(ULONG thread_id, int sig)
INT pthread_kill(ALIGN_TYPE thread_id, int sig)
INT pthread_sigmask(int how, const sigset_t *newmask, sigset_t *oldmask)

View File

@@ -24,7 +24,7 @@
/* EKP DEFINITIONS RELEASE */
/* */
/* signal.h PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -39,7 +39,10 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Update pthread_kill argument */
/* type, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -100,7 +103,7 @@ typedef struct signal_info_struct
/* Define public POSIX routines. */
int signal(int signo, void (*func)(int));
int pthread_kill(ULONG thread, int sig);
int pthread_kill(ALIGN_TYPE thread, int sig);
int sigwait(const sigset_t *set, int *sig);
int sigemptyset(sigset_t *set);
int sigaddset(sigset_t *set, int signo);

View File

@@ -24,7 +24,7 @@
/* EKP DEFINITIONS RELEASE */
/* */
/* tx_posix.h PORTABLE C */
/* 6.1.7 */
/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -39,7 +39,10 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
/* 10-31-2022 Scott Larson Update WORK_REQ_SIZE value, */
/* update pthread_t typedef, */
/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -65,6 +68,13 @@
#define MQ_FLAGS 0
#define MQ_PRIO_MAX 32 /* Maximum priority of message. */
#ifdef TX_64_BIT
#define TX_POSIX_MESSAGE_SIZE 5
#define TX_POSIX_QUEUE_PRIORITY_OFFSET 3
#else
#define TX_POSIX_MESSAGE_SIZE 4
#define TX_POSIX_QUEUE_PRIORITY_OFFSET 2
#endif
/************************************************************************/
/* Global Variables */
/************************************************************************/
@@ -254,7 +264,7 @@ typedef ULONG BOOL;
/* these constants control internal working of the systemmanager thread */
#define WORK_REQ_SIZE TX_2_ULONG
#define WORK_REQ_SIZE (TX_2_ULONG * (sizeof(ALIGN_TYPE)/sizeof(ULONG)))
#define WORK_QUEUE_DEPTH 10
#define SYSMGR_PRIORITY 0
@@ -279,7 +289,7 @@ typedef struct pthread_attr_obj
typedef INT ssize_t ; /* this should be pulled in from sys\types.h */
typedef ULONG pthread_t;
typedef ALIGN_TYPE pthread_t;
typedef ULONG mode_t;