About threads in a service process

by rktb » Sat, 14 Mar 2009 05:01:19 GMT


Sponsored Links
 i,

- What do the methods startThreadPool() and joinThreadPool() do during
the process of launching a service, e.g., mediaplayer service in the
file main_mediaserver.cpp?
int main(int argc, char** argv)
{
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm = defaultServiceManager();
LOGI("ServiceManager: %p", sm.get());
AudioFlinger::instantiate();
MediaPlayerService::instantiate();
CameraService::instantiate();
ProcessState::self()->startThreadPool();
IPCThreadState::self()->joinThreadPool();
}

- I have a service that I am using and see multiple threads on the
server side. Below is a snippet of the log.
03-13 19:52:58.143 26 45 V IMyTest: BnMyTest::onTrasact ...
tid=45
03-13 19:52:58.143 26 44 V IMyTest: BnMyTest::onTrasact ...
tid=44
03-13 19:52:58.183 26 26 V IMyTest: BnMyTest::onTrasact ...
tid=26
03-13 19:52:58.213 26 45 V IMyTest: BnMyTest::onTrasact ...
tid=45
03-13 19:52:58.213 26 44 V IMyTest: BnMyTest::onTrasact ...
tid=44
03-13 19:52:58.233 26 45 V IMyTest: BnMyTest::onTrasact ...
tid=45
03-13 19:52:58.233 26 26 V IMyTest: BnMyTest::onTrasact ...
tid=26
03-13 19:52:58.233 26 184 V IMyTest: BnMyTest::onTrasact ...
tid=184

If I read this correctly, the service is running on a process with
pid=26. But, the "onTransact" calls happen on multiple threads. I did
verify that the "Transact" calls occur in all one thread (on the
application process). Though there appear to be multiple threads (ids)
running, it looks like the calls are serialized. How come there are
multiple threads? Is there a way to control the number of threads
running on the server process?


Thanks,
Ravi


On Feb 12, 3:13pm, rktb <yend...@pv.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



About threads in a service process

by Freepine » Sat, 14 Mar 2009 08:50:13 GMT


 tartThreadPool() will spawn a new thread into the thread pool which talks
with binder driver, while joinThreadPool() will put the calling thread
itself into thread pool.

It seems there is no API to control the maximum number of binder threads in
the pool, and sometimes driver will tell the process to spawn new thread
automatically via BR_SPAWN_LOOPER command.

On Sat, Mar 14, 2009 at 1:01 PM, rktb <yend...@pv.com> wrote:


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


About threads in a service process

by rktb » Sat, 14 Mar 2009 13:34:40 GMT


 ut, these threads don't run concurrently...right? I am trying to
understand what kind of precautions the native library needs to take
in the case of multiple threads.

-Ravi

On Mar 14, 3:49am, Freepine <freep...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



About threads in a service process

by Dianne Hackborn » Sun, 15 Mar 2009 02:17:21 GMT


 es they run concurrently, that is why they are separate threads. :)

Currently the maximum number of threads in a process's thread pool is 16.

On Sat, Mar 14, 2009 at 6:34 AM, rktb <yend...@pv.com> wrote:



--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support. All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~



About threads in a service process

by rktb » Sun, 15 Mar 2009 03:05:32 GMT


 ianne's earlier response on binders and services:
http://groups.google.com/group/android-developers/msg/d76e607aa62c1cad



On Mar 14, 9:17pm, Dianne Hackborn <hack...@android.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



About threads in a service process

by rktb » Sun, 15 Mar 2009 03:09:43 GMT


 hanks Dianne.

I think I am missing something very basic here. Please help me out.
The way I understand it, atleast through the logs, all IPC calls
across the binder are synchronous, i.e., Transact and corresponding
OnTransact calls are serialized. Then, how could the threads run
concurrently? Is this the case when two applications are accessing the
same service?

-Ravi

On Mar 14, 9:17pm, Dianne Hackborn <hack...@android.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



About threads in a service process

by rktb » Sun, 15 Mar 2009 04:10:49 GMT


 nother article about threads and binders:
http://www.angryredplanet.com/~hackbod/openbinder/docs/html/BinderThreading.html

On Mar 14, 10:09pm, rktb <yend...@pv.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



About threads in a service process

by Dave Sparks » Mon, 16 Mar 2009 17:04:37 GMT


 nless otherwise specified, all binder calls are synchronous to the
calling process (usually referred to as the client process). They are
completely asynchronous to the callee (usually referred to as the
server process).

What this means is that the caller will block in the binder call until
the server thread has completed the requested action. On the server
side, the binder request is picked up by on the worker threads, it
proceeds serially until the work is complete, and then returns the
result to the caller across the binder. It is possible for multiple
worker threads to be concurrent within the server process acting on
behalf of different clients, and perhaps even different threads of the
same client.

On Mar 14, 8:09 pm, rktb <yend...@pv.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



About threads in a service process

by rktb » Mon, 16 Mar 2009 21:15:36 GMT


 hanks Dave.

On Mar 16, 12:04pm, Dave Sparks <davidspa...@android.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Android File System Permission (Accessing Private folder in file system)

Hi,

I am facing problem while accessing private folder like "/data/app"
from program in android.
Can you suggest me how to access private folder in android using
programming or suggest some other way to do this.
This will be great help for me.

Thanks & Regards,
vinay yadav
vinay.ya...@sofmen.com

-- 

2. Crash in call to opeCameraHardware()

Hi,

I trying to use the Qualcomm (libqcamera) Camera HAL to connect to
camera. I used the static function openCameraHardware() of ui/
CameraHardwareInterface.h to connect to the camera but I get
segmentation fault.

Following is the code that I used -
  sp<android::CameraHardwareInterface> chi;
  chi= android::openCameraHardware();


Following is the crash dump --

V/QualcommCameraHardware(  398): createInstance: E
V/QualcommCameraHardware(  398): constructor EX
V/QualcommCameraHardware(  398): setParameters: E params = 0xbece13d8
V/QualcommCameraHardware(  398): requested size 480 x 320
V/QualcommCameraHardware(  398): actual size 480 x 320
V/QualcommCameraHardware(  398): initCameraParameters: E
V/QualcommCameraHardware(  398): loading libqcamera
V/QualcommCameraHardware(  398): waiting for REX to initialize.
V/QualcommCameraHardware(  398): Received REX-ready signal.
V/QualcommCameraHardware(  398): REX is ready.
V/QualcommCameraHardware(  398): starting REX emulation
V/QualcommCameraHardware(  398): init camera: waiting for QCS_IDLE
I/DEBUG   (   32): *** *** *** *** *** *** *** *** *** *** *** *** ***
*** *** ***
I/DEBUG   (   32): Build fingerprint: 'htc_asia_india/htc_magic/
sapphire/sapphire:1.5/2.16.720.2/38755:user/release-keys'
I/DEBUG   (   32): pid: 398, tid: 404  >>> com.marakana <<<
I/DEBUG   (   32): signal 11 (SIGSEGV), fault addr 0000081a
I/DEBUG   (   32):  r0 a94aa8a8  r1 0000081a  r2 a94aa8a8  r3 00000008
I/DEBUG   (   32):  r4 a94aa8a8  r5 a94c77dc  r6 a94cea3c  r7 bece12dc
I/DEBUG   (   32):  r8 45253e38  r9 afe39dd0  10 a949bec1  fp 00000001
I/DEBUG   (   32):  ip a94c78ec  sp 45353e1c  lr a9419a4f  pc
afe1b97c  cpsr 80000030
I/DEBUG   (   32):          #00  pc 0001b97c  /system/lib/libc.so
I/DEBUG   (   32):          #01  pc 00019a4c  /system/lib/
libqcamera.so
I/DEBUG   (   32):          #02  pc 00093396  /system/lib/
libqcamera.so
I/DEBUG   (   32):          #03  pc 00094094  /system/lib/
libqcamera.so
I/DEBUG   (   32):          #04  pc 0008ab58  /system/lib/
libqcamera.so
I/DEBUG   (   32):          #05  pc 0009b4d0  /system/lib/
libqcamera.so
I/DEBUG   (   32):          #06  pc 0009b71a  /system/lib/
libqcamera.so
I/DEBUG   (   32):          #07  pc 0009bf08  /system/lib/
libqcamera.so
I/DEBUG   (   32):          #08  pc 0000f880  /system/lib/libc.so
I/DEBUG   (   32):          #09  pc 0000f3f4  /system/lib/libc.so
I/DEBUG   (   32): stack:
I/DEBUG   (   32):     45353ddc  00000000
I/DEBUG   (   32):     45353de0  00000000
I/DEBUG   (   32):     45353de4  00000000



Regards
Mayank

-- 

3. transforming an activity to a modal full screen dialog

4. Thursday, March 11 - Mass GTUG meeting - Android Development - Developer Perspective

5. Difference between auto sleep mode and pressing the power button when using Alarms?

6. March 11th, 6-8 pm Mass GTUG meeting - Android Development - Developer Perspective

7. Help me to select some days from a calendar base on some dates that I have please