Browse Prior Art Database

Freeing Thread Stacks in OS/2 using the ALPs Begin and End Thread APIs

IP.com Disclosure Number: IPCOM000110302D
Original Publication Date: 1992-Nov-01
Included in the Prior Art Database: 2005-Mar-25
Document File: 2 page(s) / 71K

Publishing Venue

IBM

Related People

Wilson, J: AUTHOR

Abstract

This article is related to the IBM Automated Logistics and Production Solutions (ALPS) offering. Disclosed is the ALPS Thread Begin and End APIs.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 53% of the total text.

Freeing Thread Stacks in OS/2 using the ALPs Begin and End Thread APIs

       This article is related to the IBM Automated Logistics
and Production Solutions (ALPS) offering.  Disclosed is the ALPS
Thread Begin and End APIs.

      The ALPS Thread Begin and End routines, unlike the C and OS/2*
functions, free the stack of a given thread once it has terminated.
In OS/2, applications can start threads to do certain tasks such as:
 -  Monitor a communication port.
 -  Verify data has been written to disk.
 -  Send an interprocess message to another application.

      Threads are used so that application can do multiple jobs at
the same time.

      Threads started with the C or OS/2 functions require a stack.
The problem arises when the thread is terminated.  When a thread
ends, the stack space allocated for the thread must be freed so that
the memory can be given back to the operating system.  The C function
end_thread and the OS/2 function DosExit do not free the memory
associated with the thread stack.  This is the problem that the ALPS
function thread_ begin and thread_end addresses.

      In order to free a thread stack, the thread must be terminated
completely.  Freeing a thread stack before the thread has completed
could cause undesirable results such as program segment violations.

      The ALPS functions thread_begin and thead_end use a unique and
affective algorithm to free stack space.  The following high level
pseudo-code illustrates the algorithm.
THREAD_BEGIN (EXAMPLE_FUNCTION, STACK SIZE)
if the thread monitor
has not been started
then start it        ----------------> THREAD MONITOR
wait for thread semaphore to clear  Wait for Clear Stack Semaphore
set semaphore
              ...