4dsdev
Views: 1,609,056 Main | Rules/FAQ | Memberlist | Active users | Last posts | Calendar | Stats | Online users | Search 11-21-24 08:59 AM
Guest:

0 users reading Homebrew coding pitfalls | 1 bot

Main - Homebrew discussion - Homebrew coding pitfalls Hide post layouts | New reply


StapleButter
Posted on 12-04-14 01:50 PM (rev. 2 of 12-08-14 11: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 Hide post layouts | New reply

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