Commit graph

7 commits

Author SHA1 Message Date
Solomon Peachy
ee3894f285 threads: Move stack_size to end of struct thread (followup to f19ffe2)
Makes the structure more compact.

Fixes the build failure on the m68k M5 target

Change-Id: If17b872f4923d3a52b344e3c59ed6f870d5a7725
2020-04-05 15:55:38 +02:00
Solomon Peachy
191ffe272b Threading: Use 'size_t' for stack size in core threading code
For some reason it was defined as 'unsigned short' but all arguments to
the threading functions and other structs used size_t.  The SDL plugin
tried to allocate a 2MB stack and this resulted in much badness.

This is a _very_ old bug, and might be responsible for countless subtle
bugs!

Change-Id: I8b7fd79a10c21e3ab524a89b4d40d9afa4fab638
2020-04-05 05:47:04 +02:00
Michael Sevakis
4d4b0c5a07 In queue_wait_w_tmo, guarantee wait duration
It is possible to have a thread awoken and subsequently the message
that was placed in the queue has been removed by the time the thread
is able to check the queue. Ensure theads that failed to find a
message do not return prematurely.

It was at worst imprecise when a timeout is specified. It's entirely
incorrect if the function ever returns with SYS_TIMEOUT when using
TIMEOUT_BLOCK.

Change-Id: Ibd41eae8c787adf7a320a24603cf64ff8a6da66a
2017-02-02 23:51:55 -05:00
Michael Sevakis
5b08f1a5b9 Remove I/O priority. It is harmful when used with the new file code.
HAVE_IO_PRIORITY was defined for native targets with dircache.

It is already effectively disabled for the most part since dircache no
longer lowers its thread's I/O priority. It existed primarily for the
aforementioned configuration.

Change-Id: Ia04935305397ba14df34647c8ea29c2acaea92aa
2014-08-30 14:01:21 -04:00
Michael Sevakis
6ed00870ab Base scheduler queues off linked lists and do cleanup/consolidation
Abstracts threading from itself a bit, changes the way its queues are
handled and does type hiding for that as well.

Do alot here due to already required major brain surgery.

Threads may now be on a run queue and a wait queue simultaneously so
that the expired timer only has to wake the thread but not remove it
from the wait queue which simplifies the implicit wake handling.

List formats change for wait queues-- doubly-linked, not circular.
Timeout queue is now singly-linked. The run queue is still circular
as before.

Adds a better thread slot allocator that may keep the slot marked as
used regardless of the thread state. Assists in dumping special tasks
that switch_thread was tasked to perform (blocking tasks).

Deletes alot of code yet surprisingly, gets larger than expected.
Well, I'm not not minding that for the time being-- omlettes and break
a few eggs and all that.

Change-Id: I0834d7bb16b2aecb2f63b58886eeda6ae4f29d59
2014-08-16 05:15:37 -04:00
Michael Sevakis
981d028c09 Do some kernel cleanup
* Seal away private thread and kernel definitions and declarations
into the internal headers in order to better hide internal structure.

* Add a thread-common.c file that keeps shared functions together.
List functions aren't messed with since that's about to be changed to
different ones.

* It is necessary to modify some ARM/PP stuff since GCC was complaining
about constant pool distance and I would rather not force dump it. Just
bl the cache calls in the startup and exit code and let it use veneers
if it must.

* Clean up redundant #includes in relevant areas and reorganize them.

* Expunge useless and dangerous stuff like remove_thread().

Change-Id: I6e22932fad61a9fac30fd1363c071074ee7ab382
2014-08-08 01:59:59 -04:00
Thomas Martitz
382d1861af kernel: Break out kernel primitives into separate files and move to separate dir.
No code changed, just shuffling stuff around. This should make it easier to
build only select parts kernel and use different implementations.

Change-Id: Ie1f00f93008833ce38419d760afd70062c5e22b5
2014-03-03 18:11:57 +01:00