lkml.org 
[lkml]   [2004]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Read from file fails


Libor Vanek wrote:

>>>>>OK - how can I "notify" userspace process? Signals are "weak" - I need
>>>>>to send some data (filename etc.) to process. One solution is "on this
>>>>>signal call this syscall and result of this syscall will be data you
>>>>>need" - but I'd prefer to handle this in one "action".
>>>>
>>>>My first thoughts are to make it a blocking call.
>>>
>>>You mean like:
>>>- send signal to user-space process
>>>- wait until user-space process pick ups data (filename etc.), creates
>>>copy of file (or whatever) and calls another system call that he's finished
>>>- let kernel to continue syscall I blocked
>>>?
>>
>>No, more like:
>>- user-space process calls syscall, which blocks.
>>- kernel captures a file write event, puts the info in some kind of
>>queue, wakes up the user-space process and then waits for some kind of
>>acknowledgement to be returned so that it may continue.
>>- user-space process wakes up, the syscall completes, and passes a
>>filename etc. to user-space. Copies the file, and calls a syscall to
>>signify "hey, I'm done with that file". This syscall wakes up the kernel
>>stuff that was waiting for this acknowledgement.
>>- file write event continues
>>- repeat from start
>
> OK - I'm thinking of using semaphores to "block" system call - is there something why this is not a good idea?

Semaphores are useful to protect a shared resource (and you might want
to use those to protect your queue of filenames to copy), but not for
transferring control between threads. I think you might want to look at
wait_queue, wait_event, wake_up and things like that.

--Bart
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:02    [W:0.073 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site