Skip to main content

javacall and MT safe

1 reply [Last post]
chukmunnlee
Offline
Joined: 2004-01-14
Points: 0

Hi

I'm currently porting the phoneme feature to a new platform. I've implemented the memory layer (eg. memory.c - javacall_memory_heap_allocate()) in javacall. The memory.c has some data structure that keeps track to the number of byte request by heap from PCSL.

Currently I've not done any locking when I access and modify these structure. Donuts seem to run okay on them (but then again Donuts is a single threaded app). My question is should I assume that in a multi threaded Java app, the JVM will call the lower level javacall (and also PCSL C) routines in a threadsafe manner or do I assume that calls are never threadsafe and my routines should do the right thing.

Thanks

Regards
Chuk

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
danila
Offline
Joined: 2006-09-25
Points: 0

Hi Chuk,

CLDC VM uses green threads, so all Java threads are created and managed
by the VM within a single OS thread. So the VM calls PCSL routines
from the same thread.

An exception to this rule is hybrid thread coding style that allows to use additional native OS threads to handle blocking calls.
For more details see
http://java.sun.com/javame/reference/docs/cldc-hi/doc/architecture/html/...
http://java.sun.com/javame/reference/docs/cldc-hi/doc/porting/html/chapt...

Danila