Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - First time device open is taking more time: (5 Items)
   
First time device open is taking more time  
Hi

I have written a resource manager in this when first time device is opened the time taken is taking around 134 ms. But 
later on it is taking only 0us.
I am not sure why this is taking this time as i am not doing any thing specific in open also it is not doing any device 
specific operation.
i am doing just open ("/dev/dev1/device1") followed by this i am opening second device then third altogether i am 
opening 5 devices. 
Strange part is first time device open is taking this time. for second and third devices it is taking only 0 us.
If i interchange the calling order of devices for e.g. if i open device 2 then device 1. then device2 open will take 132
 ms 

 

Any suggestion is of great help

Regards
sobin
Re: First time device open is taking more time  
Two things can contribute to thie first-time delay:
1) loading code of your resource manager that never ran before from media into RAM. Later, it will come from cache.
2) allocating stack pages on first use.

regarding 1), try to copy executable to RAM disk and see if this has an influence
regarding 2), make all stacks not-lazy, or do a suffucient dummy alloca() statement to force stack page allcoation 
(remember, main() thread stack attributed cannot be changed since it is already running)

You can also run a kernel trace while doing the first accesses to your resource manager, and you will see both events.

Regards,
Albrecht

Re: First time device open is taking more time  
Hi 

Thanks for prompt reply I tried allocating stack space of 500 bytes using alloca

Also tried moving the resource manager executable to ram file system by

cp /dev/driver1 /dev/shmem

also 
tried 
cp /dev/driver1 /tmp

Unfortunately its not causing any difference in the time.
Can you tell me any other way to move the resource manager code to RAM. 

Can you help here. Also let me know how to use kernel trace.

regards
Sobin
Re: First time device open is taking more time  
Hi

It seems there was problem in the configuration of maximum number of threads in blocked state.
This is very strange. 
The resource manager is multithreaded resource  manager and not sure why the configuration will effect in this way.

regards
Sobin
Re: First time device open is taking more time  
Hi Thomas,
sounds plausible. I remember having read that the Thread Pool evaluates if new threads need to be created after 
reception, but before processing a new message. If your thread pool was configured such that the number of pre-existing 
threads is less than number of RECEIVE blocked threads, this will cause the issue.

Bu this means that depending on the nature of your resource manager, if it has potentially many clients, each client may
 occcasionally expereince the same delay at runtime.

Some people create a steady-state thread pool by having all four attributes set to the same value.

Regards,
Albrecht