The following demo outputs "Hello, World!" individually, from the main core, sub-Core 1, and sub-Core 2.
The following demo shows how to allocate the default heap memory from multiple cores. The default heap is created thread-safe.
The following demo shows how to create a heap for each core and allocate memory independently.
By limiting the access of any given heap to only one thread at one time, the need for exclusive control is eliminated. This allows users to access the heap quickly.
In the following demo, data is inserted into the linked list using three threads, and then the three threads sort the data simultaneously. To prevent multiple threads from accessing the linked list at the same time and possibly destroying it, the linked list is protected by the use of spinlock.
In the following demo, six threads increment values in the buffer 10 times each. There are two buffers, one of
which is protected by
Mutex and the other of which is not. Thread synchronization for the protected
buffer means accurate computation results.
In the following demo, six threads share two resources. Using semaphores, the number of resources to be used at the same time is limited to two.
The following demo uses three threads to compute the sum of numerical values in the data array. Because this sum is recorded into the global variable protected by spinlock, multiple threads fight over the spinlock. This type of spinlock, called a hot lock, contributes to performance deterioration.
The following demo uses three threads to compute the sum of numerical values in the data array. Each thread records the sum into the local variable for that thread. When computation on each thread finishes, the demo gets a spinlock only once, and combines the sum of each thread into the sum of the total.
By using local variables for each thread, the number of incidents requiring the spinlock may be reduced, which helps resolve the hot lock issue.
The following demo uses three threads to compute the sum of numerical values in the data array. Each thread
records the sum in the global variable by using the
OSAtomic API. The
functions change variables atomically, so it is not necessary to protect variables with a spinlock. If the critical
section has only one variable, the processing speed can improve by using the
One Producer places 18 items into the buffer for six consumers. The maximum number of items that can be stored in the buffer is four.
In the following demo, six clients obtain three IDs, each from one ID-generating server. The clients and server use the message queue to exchange.
In the following demo, six clients obtain three IDs each from one ID-generating server, and uses events as notification of the sending and receiving requests.
2013-05-08 Automated cleanup pass.
2013-03-20 Converted to HTML.