下面是OSQCreate()的源代码: OS_EVENT *OSQCreate (void **start, INT16U size) { #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */ OS_CPU_SR cpu_sr; #endif OS_EVENT *pevent; OS_Q *pq;
if (OSIntNesting > 0) { /* See if called from ISR ... */ return ((OS_EVENT *)0); /* ... can't CREATE from an ISR */ } OS_ENTER_CRITICAL(); pevent = OSEventFreeList; /* Get next free event control block */ if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB pool was empty */ OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr; } OS_EXIT_CRITICAL(); if (pevent != (OS_EVENT *)0) { /* See if we have an event control block */ OS_ENTER_CRITICAL(); pq = OSQFreeList; /* Get a free queue control block */ if (pq != (OS_Q *)0) { /* Were we able to get a queue control block ? */ OSQFreeList = OSQFreeList->OSQPtr; /* Yes, Adjust free list pointer to next free*/ OS_EXIT_CRITICAL(); pq->OSQStart = start; /* Initialize the queue */ pq->OSQEnd = &start[size];/*Error*/ pq->OSQIn = start; pq->OSQOut = start; pq->OSQSize = size; pq->OSQEntries = 0; pevent->OSEventType = OS_EVENT_TYPE_Q; pevent->OSEventCnt = 0; pevent->OSEventPtr = pq; #if OS_EVENT_NAME_SIZE > 1 pevent->OSEventName[0] = '?'; /* Unknown name */ pevent->OSEventName[1] = OS_ASCII_NUL; #endif OS_EventWaitListInit(pevent); /* Initalize the wait list */ } else { pevent->OSEventPtr = (void *)OSEventFreeList; /* No, Return event control block on error */ OSEventFreeList = pevent; OS_EXIT_CRITICAL(); pevent = (OS_EVENT *)0; } } return (pevent); } 下面是邵老师一书中提供的源代码,请问有没有问题 OS_EVENT *CommQ; void *CommMsgp[10]; void main(void) { OSInit(); . . . CommQ = OSQCreate(&CommMsg[0],10);/*注此处是否有问题看上面Error标注位置是否会出现数组溢出的问题*/ OSStart(); } pq->OSQEnd = &start[size];/*Error*/ *注此处是否有问题看上面Error标注位置是否会出现数组溢出的问题*/
|