4dsdev
Views: 603,628 Main | Rules/FAQ | Memberlist | Active users | Last posts | Calendar | Stats | Online users | Search 10-18-17 11:37 PM
Guest:

0 users reading Homebrew coding pitfalls | 1 bot

Main - Homebrew discussion - Homebrew coding pitfalls New reply


StapleButter
Posted on 12-04-14 08:50 AM (rev. 2 of 12-08-14 06:27 PM) Link | #50
Threading

Threading on the 3DS is cooperative. That means that threads in your app need to be responsible and not take all the CPU time.

Calling any system function (anything that uses SVC calls) triggers scheduling and gives other threads a chance to run.

However, if you have a thread that does time-consuming operations without any system call, it will prevent other threads from running until it terminates or does a system call.

In such cases, you should insert regular dummy system calls (for example svcSleepThread(1)) within the operations.

This restriction only applies to threads from the same process on the same CPU core.


Memory allocation

When passing buffers to GPU or CSND calls, they must be allocated with linearAlloc().


Writing assembly code

Take note of this when writing assembly code in a userland app.

Code goes in .text, data goes in .data.

Mess this up and you'll crash. It may seem common sense, but it is important on a system like the 3DS. The 3DS security implies that .text is read-only and code can't execute from .data.

(in particular, you may run into this issue if you're porting ASM code from GBA/DS homebrew)

____________________
blargSNES -- SNES emu for 3DS
More cool stuff


Main - Homebrew discussion - Homebrew coding pitfalls New reply

Page rendered in 0.025 seconds. (2048KB of memory used)
MySQL - queries: 28, rows: 65/65, time: 0.019 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2015-10-07)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.