Re: Linux question , please help a newbie!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If your aim is to timeout a interruptible semaphore acquisition,
so that a process continues with another task if the task is not completed
within given period of time
Following code snippet was suggested:
   DOWN_VAR
        DOWN_HEAD(TASK_INTERRUPTIBLE)
        if ( waking_non_zero(struct semaphore *) )
               return 0; /* semaphore already acquired */

        if (schedule_timeout(ticks) == 0)
        {
     return 0;    /* process signalled before timeout */
        }
        DOWN_TAIL(TASK_INTERRUPTIBLE)
   return 1; /* successfull acquisition and release of semaphore ,  before
timeout*/

OR
you can use interruptible_sleep_on_timeout() which will wakeup after the
specified timeinterval.

regards
lk
----- Original Message ----- 
From: "Garcia Jérémie" <GARCIAJ@xxxxxx>
To: <tomazb@xxxxxxxxxxx>
Cc: <kernelnewbies@xxxxxxxxxxxx>
Sent: Monday, June 27, 2005 6:51 PM
Subject: Linux question , please help a newbie!


> Hi Tom,
> I'm looking for a solution to a problem you posted on the net 2 years ago.
> I need to be able to interrupt a task that is waiting for a semaphore to
be free.
> Indeed I use "down_interruptible()" and I'd like to be able to tell to the
task
> after a period of time : "give up, awake and do something else".
> You did not give the solution on the list. So do you have it or do you
remember what to
> do cause it was a long time ago lol!
> Tks, Jérémie
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
>
>



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux