2010-01-07 04:18:09     chdir operation blocks application

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2010-01-07 04:18:09     chdir operation blocks application

Hari Prasad (INDIA)

Message: 84278   

 

Hi,

 

I have an application 'X' that plays songs from usb. I have a requirement where I have to recursively scan mnt/usb and determine the number of files and folders in it. For this I wrote a small application 'Y' that does the following:

 

for each entry in mnt/usb

 

{

 

    check if entry is file or folder using chdir( ) function.

 

}

 

The entry is a file if chdir returns false and is a folder if it returns true.

 

Using a usb stick with 5000 files and my custom board with BF527 processor, I started first application X and my audio playback started. When I started application Y, it blocked the playback till chdir operation on all the entries in mnt/usb was done.

 

Why is that a chdir operation blocks resource for application X?

 

Please clarify.

QuoteReplyEditDelete

 

 

2010-01-07 10:21:47     Re: chdir operation blocks application

Robin Getz (UNITED STATES)

Message: 84280   

 

Hari:

 

I could be that you are consuming all the bandwith of the usb stick (most are pretty slow).

 

To give things some more time - try sleeping in the application "Y".

 

Also lookup the "man 2 stat" page - and read about the S_IFDIR() macro. That might be faster than doing a chdir, and looking for the failure.... (although you would have to measure to be sure).

 

-Robin

QuoteReplyEditDelete

 

 

2010-01-07 11:32:40     Re: chdir operation blocks application

Mike Frysinger (UNITED STATES)

Message: 84281   

 

stat() probably would be better than chdir() ... although if you're using readdir(), you probably want to use the d_type field of the dirent structure

Attachments

    Outcomes