Commit Graph

81 Commits

Author SHA1 Message Date
Karoly Balogh
88c7954d9f rtl: add two defines toallow disabling the verbose error of the stub unicodestringmanager and threadmanager 2024-02-20 03:56:17 +01:00
marcoonthegit
452ec93f06 * implement waitformultiple for win32 only.
* Change interface to allow for COM waiting + a basic windows implementation. (only for desktop apps? Use msgwait* for the rest?)
2023-05-20 14:37:26 +02:00
Jonas Maebe
0758aa1143 FPU exception mask: generlised system unit interface 2022-10-17 19:43:01 +00:00
ondrej
a65158bfe8 * fix memory leak in RegisterLazyInitThreadingProc
git-svn-id: trunk@47311 -
2020-11-04 20:10:43 +00:00
ondrej
c64429cdd0 * lazy thread initialization support
git-svn-id: trunk@47308 -
2020-11-04 14:55:40 +00:00
michael
213d2905df * Change some methods from using var to using out (bug ID 37376)
git-svn-id: trunk@46533 -
2020-08-21 10:44:48 +00:00
svenbarth
c8b7094378 * fix for Mantis #36940: apply (adjusted) patch by Bi0T1N to add functionality to the thread manager to set a thread's debug name (if supported by the platform)
git-svn-id: trunk@45160 -
2020-04-28 19:58:20 +00:00
florian
5ed2475c85 * InitThread variant without parameters as user threads normally cannot know the max. stack size
git-svn-id: trunk@43068 -
2019-09-25 21:19:01 +00:00
marco
8c854cedee * more case fixes, mantis #32832 manually done.
git-svn-id: trunk@38865 -
2018-04-29 14:05:09 +00:00
michael
16ba47be46 * Patch from Ondrej Pokorny to convert unit names to CamelCase (bug ID 33481)
git-svn-id: trunk@38616 -
2018-03-23 22:06:36 +00:00
sergei
67bd4775fd - Cleaned out thread manager semaphore support which was ever implemented only for Unix, and not used since r28965. This also reverts changes to System unit interface introduced in r27665.
git-svn-id: trunk@34542 -
2016-09-20 20:14:36 +00:00
pierre
cbb29a7e5d Use FPC_NO_DEFAULT_HEAP to turn out RelocateHeap or MemoryManager.InitThread functions, used for msdos OS
git-svn-id: trunk@33679 -
2016-05-11 14:34:55 +00:00
nickysn
12a9664181 * use 16-bit offsets for threadvars on CPUs with 16-bit address space
git-svn-id: trunk@32013 -
2015-10-11 12:16:26 +00:00
sergei
d7c863185f * Added plain calls for semaphore-related functionality, this removes need to maintain a second copy of thread manager in unis/tthread.inc.
git-svn-id: trunk@27665 -
2014-04-26 13:58:35 +00:00
svenbarth
764f36a179 Extend TThread with (class) methods and (class) properties from Delphi 2007 and newer.
Especially for the introduction of the Queue method the internal Synchronize handling was modified. Instead of handling only one event there is now a queue of events which is walked completely when CheckSynchronize is called. Each entry in the queue can carry a PRTLEvent which will be signaled when the contained method has been executed and thus Synchronize methods can still be blocking.
Exceptions inside the queued methods are either handed back to the calling method for Synchronize events or raised directly (after leaving the queue in a valid state) to the caller of CheckSynchronize.

The way platform specific adjustments can be made to TThread was changed. Instead of implementing the Constructor and Destructor directly one now implements the methods SysCreate and SysDestroy which are called from the Constructor and Destructor respectively. All RTLs were adjusted for this and should be controlled by the platform maintainers for correct compilation (Unix works).

The new method NameThreadForDebugging has two overloaded variants: one with the thread name as AnsiString and one with the thread name as UnicodeString.
By default the AnsiString variant calls the UnicodeString variant and the latter needs to be implemented. This can be changed by defining THREADNAME_IS_ANSISTRING for a platform. Then the UnicodeString variant calls the AnsiString one and the AnsiString one needs to be implemented.

Also added was a global property CPUCount for the System unit. This property returns the number of virtual cores of the system.

New methods and functions that should be implemented per platform are:
System.GetCPUCount (default returns 1)
Classes.TThread.GetSystemTimes (default zeros the struct)
Classes.TThread.NameThreadForDebugging (default does nothing)

More detailed information about the added methods will be available in the feature announcement mail.

git-svn-id: trunk@23227 -
2012-12-27 16:16:17 +00:00
pierre
70a29668a4 Try to fix simply the fpc_threadvar_relocate_proc problem
git-svn-id: trunk@23220 -
2012-12-24 16:23:30 +00:00
Jonas Maebe
14b1c8a99c * moved fpc_threadvar_relocate_proc from systemh.inc to thread.inc
and gave it the correct type (TRelocateThreadVarHandler)
  * changed parameter type of InitThread also to TRelocateThreadVarHandler

git-svn-id: trunk@23130 -
2012-12-09 22:42:46 +00:00
Jonas Maebe
dfe59e6838 - removed unimplemented/unsupported rtleventsync (mantis #23332)
git-svn-id: trunk@23012 -
2012-11-18 10:23:48 +00:00
pierre
4a9c8e330b + Move EXEC_callback into separate file win/systlsdir.inc
* In win32/sysinitXX units, rename EntryInforation
    to SysInitEntryInformation.
    include new win/systlsdir.inc file from
    win/syswin.inc for win64 target
    and from win32/sysinit.inc for win32 target.
    Set fields of both SysInitEntryInformation and EntryInformation
    by converting them into typed constants.

git-svn-id: trunk@19779 -
2011-12-08 16:11:07 +00:00
florian
f14e0a25c6 * reduce code size of dummy threading routines
* threading manager of the embedded target uses only one dummy routine to reduce code size

git-svn-id: trunk@19169 -
2011-09-21 21:00:15 +00:00
sergei
24c3a43b35 * Call SysFlushStdio from FlushThread, instead of duplicating its functionality.
* Don't call FlushThread from EndThread, since r17798 it is called from DoneThread.

git-svn-id: trunk@18018 -
2011-07-25 06:03:40 +00:00
Jonas Maebe
d85ccd7418 * fixed compilation on targets where tthreadid is not an integer type after
r17992

git-svn-id: trunk@17993 -
2011-07-16 12:03:35 +00:00
sergei
5c3aca5148 * thread.inc, DoneThread: allow CurrentTM.ReleaseThreadVars to be unassigned and reset ThreadID (in preparation to support Windows native threadvars)
* win/systhrd.inc: added error checking in several places. Fail with code 226 if resources cannot be allocated, as Delphi does.
* win/syswin.inc, Dll_entry: Don't call DoneThread in PROCESS_DETACH callback, it is redundant because the main thread is finalized by FPC_DO_EXIT. SysReleaseThreadVars is still necessary. Also removed redundant assignments to return value.

git-svn-id: trunk@17992 -
2011-07-15 23:57:23 +00:00
pierre
2d5ca71a06 + New procedure SysFlushStdIO (code taken from InternalExit).
* InternalExit: now calls new procedure SysFlushStdIO
 * DoneThread: Also calls SysFlushStdIO to avoid loosing output
 if standard files are redirected.

git-svn-id: trunk@17798 -
2011-06-22 16:16:27 +00:00
marco
8cce3d3f91 * closethread thread manager field/function. Mantis 13160
git-svn-id: trunk@15072 -
2010-03-26 23:31:52 +00:00
marco
c477df5046 * TCriticalSection.Tryenter support (Mantis 15928) + short test/demo
tested on FreeBSD (general Unix) and Windows. Note that Haiku seems 
    to have a native threadmgr rather than the Unix one. Will notify 
    maintainer (Olivier)

git-svn-id: trunk@15026 -
2010-03-21 11:34:05 +00:00
Jonas Maebe
13e8b3f23e * don't give a "NoThreadError" for any default rtl/basicevent* routines,
so the TMultiReadExclusiveWriteSynchronizer routines can be safely
    executed even with the default thread manager -> removed ismultithread
    checks, so that it keeps working even if ismultithread is set to true
    between acquiring and freeing a lock (mantis #15619)

git-svn-id: trunk@14830 -
2010-01-29 21:01:11 +00:00
Jonas Maebe
356845ba1e * set function results for unimplemented generic thread manager routines
(to remove warnings)
  * don't give a thread error for basicevent and threadevent routines if
    isMultiThreaded is false, except for the waiting routines (the new
    TMultiReadExclusiveWriteSynchronizer creates/sets such events in the
    constructor, which caused thread manager errors in case cthreads was
    not used under unix)
  * don't perform any actual locking in TMultiReadExclusiveWriteSynchronizer
    routines if isMultiThreaded is false (in order to avoid the errors
    described above)
  + added generic RTLeventResetEvent stub

git-svn-id: trunk@14592 -
2010-01-10 11:04:05 +00:00
Jonas Maebe
0597c300f4 * applied feature dependencies patch by Sven Barth from mantis #13673 :
o i386/i386.inc used a function (fpc_truely_ansistr_unique) is now
     only included if FPC_HAS_FEATURE_ANSISTRINGS is enabled (all other
     platforms use the Pascal-only implementations)
   o inc/heap.inc relied on threading
   o inc/threads.inc relied on exceptions, consoleio and stackcheck
   o inc/system.inc: just a feature-related "variable not used"-hint

git-svn-id: trunk@13121 -
2009-05-09 20:08:57 +00:00
micha
83b7f81f81 + add no-fpu support to compiler/rtl for powerpc-linux (-Cfnone)
git-svn-id: trunk@10422 -
2008-03-02 12:59:02 +00:00
peter
5acb3649df * revert r9557, the performance impact is to big for an academic corner
case optimziation

git-svn-id: trunk@9603 -
2007-12-31 13:36:16 +00:00
yury
c4e60fd1a5 - Removed systhrd.inc from targets where thread manager is stub by default. Stub is installed in common thread.inc file if DISABLE_NO_THREAD_MANAGER is not defined.
git-svn-id: trunk@9558 -
2007-12-28 15:21:02 +00:00
yury
0dcad4d822 * Implemented late thread manager initialization. Thread manager code is not included to executable if thread stuff are not used. WinCE executable size is reduced by 4KB, Win32 executable size is reduced by 3KB. No testsuite regressions.
git-svn-id: trunk@9557 -
2007-12-28 14:40:28 +00:00
florian
7da7364ee7 * refactored SysResetFPU into SysInitFPU and SysResetFPU
git-svn-id: trunk@8966 -
2007-10-28 12:06:49 +00:00
Jonas Maebe
0d8594a705 * made cwstring thread safe without locks + test (twide4): widestring
manager now has two extra parameterless procedures (ThreadInitProc
    and ThreadFiniProc) which are called whenever a thread begins/ends,
    and cwstring uses these to create separate iconv handles for
    each thread (via threadvars)
  * renamed UCS4 to UCS-4BE/LE, because UCS4 is not recognised by most
    systems
  * clean up all iconv handles on exit, and check whether they are
    valid before doing so

git-svn-id: trunk@7949 -
2007-07-04 18:10:34 +00:00
yury
0c6fb09094 * fixed compilation for wince.
git-svn-id: trunk@7517 -
2007-05-29 17:03:03 +00:00
micha
6c85fcb157 heap manager: initialize critical sections properly
git-svn-id: trunk@7412 -
2007-05-21 17:08:28 +00:00
micha
7f2a257102 + heap manager now per thread, reduce heap lock contention
+ heap threading test

git-svn-id: trunk@7407 -
2007-05-20 20:58:12 +00:00
micha
702685717f * cleanup of rtlevents, remove startwait due to persistance guarantee
git-svn-id: trunk@5854 -
2007-01-08 19:11:07 +00:00
Jonas Maebe
0c3afc0cf4 + implementation of cSemaphore* and BasicRTLEvent based on
sem_open/sem_close for Darwin (doesn't have sem_init/sem_destroy)
  + implementation of cSemaphore* based on pipes (for potential future
    systems that don't have either sem* routines)
  + test for basicrtlevent
  * fixed datarace whereby a TThread could be started, run and exit before
    TThread.AfterConstructor had been called (Mantis 6693, all platforms)
  * throw EThread exceptions in TThread.create if something during creating
    the tthread goes wrong (*nix)
  * don't crash in TThread.Destroy if the TThread throws an exception before
    it was fully initialised (*nix)
  * changed order of operations in TThread.Destroy so it doesn't perform
    invalid thread operations in some edge cases (*nix)
  * fixed usage of sem_wait/sem_trywait (can be interrupted) in Semaphore
    and RTLEvent implementations
  * fixed erroneous waiting for threads after they had already exited via
    pthread_detach/pthread_exit
  * fixed several memory leaks in case of thread intialisation errors
    (*nix)
  * unified tthread.inc for all Unices

git-svn-id: trunk@5662 -
2006-12-21 18:22:47 +00:00
florian
fd2032dab2 + start of embedded rtl
+ feature support in the compiler

git-svn-id: trunk@5628 -
2006-12-17 18:40:36 +00:00
Almindor
2ee7e64a4a * adds semaphore support to ThreadManager, removes pipe hack from non linux
+ adds SemaphoreInit, SemaphorePost, SemaphoreWait and SemaphoreDestroy to TM

git-svn-id: trunk@4900 -
2006-10-14 11:39:47 +00:00
florian
262f60e67d * flush std handlers at thread termination
git-svn-id: trunk@4752 -
2006-09-28 20:36:41 +00:00
tom_at_work
1b4b42fdd6 * added CheckInitialStkLen() function which checks whether the given stack size value is valid on the OS when creating a thread, fixing stack checking
git-svn-id: trunk@1722 -
2005-11-11 12:16:08 +00:00
tom_at_work
367df58016 * stack related things (sizes, calculations, etc.) are now 64 bit on 64 bit platforms
* default stack size is now also 32k for Windows (allows the use of stack checking when using threads)

git-svn-id: trunk@1718 -
2005-11-10 17:06:25 +00:00
florian
7bff61ce29 * patch from Ales Katona to add a stack size parameter to tthread functions
git-svn-id: trunk@1621 -
2005-11-01 22:01:48 +00:00
florian
ad3b9b9464 * windows rtl restructuring to share code between win32 and win64
* BeginThread can take a qword on 64 bit targets as stacksize

git-svn-id: trunk@287 -
2005-06-08 19:08:49 +00:00
peter
4ace790492 * remove $Log
git-svn-id: trunk@231 -
2005-06-07 09:47:55 +00:00
Jonas Maebe
7ba46ce6f0 * Darwin TThreadID is a pointer
* BeginThread now returns a TThreadID instead of dword

git-svn-id: trunk@189 -
2005-06-04 09:33:39 +00:00
fpc
790a4fe2d3 * log and id tags removed
git-svn-id: trunk@42 -
2005-05-21 09:42:41 +00:00