This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SEM_pend on TSK_Handle

I am calling SEM_pend(handle, -1) with a TSK_Handle returned by TSK_Create. The SEM_pend returns immediately. Checking SEM_count on the handle returns a value of 1. Is a handle from TSK_Create a valid object to block on? I want to use the thread's existence/destruction to signal that I can free up resources. I'd like to avoid creating a semaphore if I can use the thread handle.

My main code creates some memory objects and then creates a worker thread that will use those objects. At some point the main thread needs to stop the worker thread and clean up the memory objects. On the PC I am able to use WaitForSingleObject(handle, -1) using the worker thread's handle to block the main thread until the worker thread exits. I do not to adjust the count value of the thread handle. I thought I had used this technique in another part of my code with earlier versions of DSP BIOS. With 5.31.02 the SEM_pend does not block. Is this a change in DSP BIOS?

If I call SEM_reset on the tsk handle before the SEM_pend then the call blocks. When the worker thread terminates, will the main thread unblock?

Thanks,

-Steve

  • Hi Steve --

    You cannot pass a TSK_Handle to SEM_pend().  How are you doing this?  Are you adding a type-cast to force a TSK_Handle into a SEM_Handle?

    We include a couple TSK/SEM examples in the product that should help.   And the threading chapter of the User's Guide might has some useful info about tasks and semaphores.

    Regards,
    -Karl-