Difference between pages "r7.1.1:Typedef lfds711 pal uint t" and "r7.1.1:Typedef libshared pal thread handle t"

From liblfds.org
(Difference between pages)
Jump to navigation Jump to search
m (1 revision imported)
 
m (1 revision imported)
 
Line 1: Line 1:
{{DISPLAYTITLE:define lfds711_pal_uint_t}}
{{DISPLAYTITLE:typedef libshared_pal_thread_handle_t}}
==Source File==
==Source File==
  └───liblfds711
  └───test_and_benchmark
     └───inc
     └───libshared
        └───liblfds711
        └───inc
                lfds711_porting_abstraction_layer_procesor.h
            └───libshared
                    libshared_porting_abstraction_layer_compiler.h


==Typedef==
==Typedef==
  typedef [type] lfds711_pal_uint_t;
  typedef [type] test_pal_thread_handle_t;
 
==Example==
typedef int long long unsigned lfds711_pal_uint_t;


==Optionality==
==Optionality==
This typedef is mandatory.
This typedef is mandatory.
==Example==
typedef HANDLE test_pal_thread_state_t;


==Notes==
==Notes==
The library needs an unsigned type which is the natural integer length for the platform, so that for example variables used to count the number of elements in a data structure naturally and inherently provide large number ranges on more capable platformsThis type is expected also to be the same length as the type used in atomic operations.
Threads typically have associated with them both an ID and a handle.
 
This typedef is for the handle - i.e. the datum which the OS can wait on for thread termination.
 
If we look at the Windows CreateThread function;
 
HANDLE WINAPI CreateThread( _In_opt_  LPSECURITY_ATTRIBUTES  lpThreadAttributes,
                            _In_      SIZE_T                dwStackSize,
                            _In_      LPTHREAD_START_ROUTINE lpStartAddress,
                            _In_opt_ LPVOID                lpParameter,
                            _In_      DWORD                  dwCreationFlags,
                            _Out_opt_ LPDWORD                lpThreadId );


In the C89 standard, there is no such type.  It should be that ''int'' works in this way, but it does not, as with Windows and Linux ''int'' is 32 bit on 64 bit platforms.
We see there is an argument, ''lpThreadId '', which receives the thread ID, but that the function returns a ''HANDLE'', which is the datum used by ''WaitForSingleObject'' to sleep until the thread has terminated.


==See Also==
==See Also==
* [[r7.1.1:Porting Guide (liblfds)|Porting Guide (liblfds)]]
* [[r7.1.1:Porting Guide (libshared)|Porting Guide (libshared)]]

Latest revision as of 20:16, 17 February 2017

Source File

└───test_and_benchmark
    └───libshared
        └───inc
            └───libshared
                    libshared_porting_abstraction_layer_compiler.h

Typedef

typedef [type] test_pal_thread_handle_t;

Optionality

This typedef is mandatory.

Example

typedef HANDLE test_pal_thread_state_t;

Notes

Threads typically have associated with them both an ID and a handle.

This typedef is for the handle - i.e. the datum which the OS can wait on for thread termination.

If we look at the Windows CreateThread function;

HANDLE WINAPI CreateThread( _In_opt_  LPSECURITY_ATTRIBUTES  lpThreadAttributes,
                            _In_      SIZE_T                 dwStackSize,
                            _In_      LPTHREAD_START_ROUTINE lpStartAddress,
                            _In_opt_  LPVOID                 lpParameter,
                            _In_      DWORD                  dwCreationFlags,
                            _Out_opt_ LPDWORD                lpThreadId );

We see there is an argument, lpThreadId , which receives the thread ID, but that the function returns a HANDLE, which is the datum used by WaitForSingleObject to sleep until the thread has terminated.

See Also