Re: pthread_suspend_np() and interrupt : system block

"pm.boyer" <[email protected]> Mon, 11 Apr 2005 16:41:41 +0200
Newsgroups gmane.linux.real-time.rtlinux.general
Message-ID <[email protected]>
Thank you for your reply,
but i must explain you more exactly my software.

I use only one rt-thread, which is blocked (and all the system with) when
it enter in the pthread_suspend_np().

( I want to use a rt-driver inside RTLinux. )

This rt-thread use a driver to send data to a PCI sound card.
( the sound card is Sound Blaster PCI 128 and i have modified a linux
     driver (es1371.c) by changing some linux call by rt-linux call ( like
     request_irq() by rtl_request_irq() ...)

Exactly i have two modules : one for the rt-driver ( with init_module(),
cleanup_module() and open(), close(), read(), write(), ioctl() functions to
access the audio card ), and one where in the init_module i open the audio
device and create a rt-thread that send audio-buffers whith the write function
to the audio card whith the write function of the driver ).

The driver use a DMA ring-buffer to send/receive data to the PCI audio card,
and an interrupt handler is installed and used by the audio card to inform
the driver after access to the DMA buffer.

The write function in the driver, write data (to send to the card) in the DMA
ring-buffer, and when the buffer is full, it call phtread_suspend_np() to wait
the card read the data from the ring-buffer through the PCI bus, when some data
are read and then space freed, the card throw an interrupt, and in the interrupt
handler the rt-thread is awakened, and then the rt-thread can continue to write
the next data to the ring-buffer.....( normally ! because this don't work )

This don't work. When the rt-thread enter in the pthread_suspend_np() function
all the system (Linux and RTLinux) block, there is no interrupt fired to wakeup
the thread, my keyboard no respond, system die.
But if i replace the pthread_suspend_np() function by usleep() function, all
work good, all seems ok ( no blocking ).

I have looked into the pthread_suspend_np() and usleep() functions, and i have
saw that they use rtl_schedule() functions too. I have put some rtl_printf()
into the rtl_schedule(), and to see which is the caller, i have rtl_printf-ed
the priority of the calling thread. (my rt-thread have priority = 4 ).
And i have saw that, some time a thread (?) whith a priority = -1 calls
rtl_schedule().
When i use usleep(), in place of pthread_suspend_np(), during the call of
usleep, into the rtl_schedule my thread whith priority 4 is replaced with
a thread with priority -1, but all seems ok and work good, my calling thread
leave usleep normally at the end of sleeping time (10ms).
But when i use pthread_suspend_np(), in the first call of rtl_schedule(), my
thread is replaced by thread of priority -1, but leave normally the rtl_schedule
function, then another call to rtl_schedule is done whith priority -1, executed
normally, ----> but after it has left the rtl_schedule function : all block !
system die. !!!!!!

Is some body can understand some thing, can help me ?

Tanks.

PS : i use RTLinux 3.2-pre1 whith linux kernel 2.4.19.





victor yodaiken wrote:

     >>From RTLinux's point of view, Linux is a single thread. So
     > pthread_suspend_np called from Linux context suspends the entire Linux
     > thread - including all Linx processes.
     >
     > You test routine should create a realtime thread that calls the driver -
     > or if the call is intended to come from Linux/User, you need to use a
     > Linux call to self-suspend.
     >
     > Also: I prefer sem_wait/sem_post to pthread_kill_np.
     >
     >
     > On Sun, 2005-03-27 at 23:40 +0200, pm.boyer wrote:
     >
     >>Hi !
     >>
     >>I am trying to test a RT-driver for audio card Ensoniq ES1371.
     >>When i test the driver, the calling program which make a
     >>write(fd,buffer,len) to the driver block all the rt-system,
     >>when the write function do a pthread_suspend_np(pthread_self())
     >>
     >>May be there is a mistake with the function pthread_suspend_np()
     >>and the fact that there is an hardware interrupt handler conneted ?
     >>
     >>( the driver write data to a DMA buffer, and when the DMA ring-buffer
     >>   become full, the driver must suspend themself to wait an interrupt
     >>   from the audio card which read and free the buffer, and
     >>   wake up the write function :
     >>   But before, when the write function enter in pthread_suspend_np() all
     >>   the system block : no activity in system, keyboard not respond )
     >>
     >>Can you help me ?
     >>
     >>Thanks.
     >>
     >>
     >>
     >>
     >>_______________________________________________
     >>Rtl mailing list
     >>[email protected]
     >>http://hq.fsmlabs.com/mailman/listinfo/rtl
     >>http:/www.rtlinux-gpl.org/
     >>









_______________________________________________
Rtl mailing list
[email protected]
http://hq.fsmlabs.com/mailman/listinfo/rtl
http:/www.rtlinux-gpl.org/