Eugene,

On Wed, 16 Jul 2003, Eugene LiS User wrote:

> Hello,
> 
> The driver I'm porting uses sleep() function calls
> in its ..._open() function.
> 
> Q1:
> Is sleep(channel, pri) a legitimate call in the LiS environment?

No, not in Linux.  These are SVR4 specific.

> 
> Q2:
> What 'include' file should I use in order to get
> PZERO PCATCH constants defined.

Don't exist in Linux.  These are SVR4 specific.

> 
> Q3:
> What would be the closest LiS/Linux equivalent to the
> sleep_spinunlock(channel, PZERO, mylock_lock)
> function.

Declare a Linux wait queue.  Add you process in open() to the
wait queue with add_wait_queue_exclusive(), set current->state =
TASK_INTERRUPTIBLE, release your spinlock, and call schedule().
In your read putp call wake_up_interruptible() with the wait
queue you declared.  Your open() routine will exit the
schedule() call.  It can then call getq().


Put this in your queue private structure:

typedef struct priv {
        .
        .
    wait_queue_head_t  *sleep;
        .
        .
} priv_t;

In open() do something like:

{
        DECLARE_WAITQUEUE(wait, current);
        add_wait_queue_exclusive(priv->sleep, &wait);
        while (!(mp = getq(RD(q)))) {
                lis_spin_unlock(mylock_lock);
                set_current_state(TASK_INTERRUPTIBLE);
                schedule();
                lis_spin_lock(mylock_lock);
        }
        set_current_state(TASK_RUNNING);
        remove_wait_queue(priv->sleep, &wait);
        /* here you have mp */
}

In your read putp() do something like.

int read_putp(queue_t *q, mblk_t *mp)
{
        priv_t *priv = q->q_ptr; 
        putq(q, mp);
        if (waitqueue_active(priv->sleep))
                wake_up_interruptible(priv->sleep);
        return (0);
}

--brian

> 
> thanks a lot for your comments.
> --
> Eugene
> 
> 
> __________________________________________________________________
> McAfee VirusScan Online from the Netscape Network.
> Comprehensive protection for your entire computer. Get your free trial today!
> http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397
> 
> Get AOL Instant Messenger 5.1 free of charge.  Download Now!
> http://aim.aol.com/aimnew/Aim/register.adp?promo=380455
> 
> _______________________________________________
> Linux-streams mailing list
> [EMAIL PROTECTED]
> http://gsyc.escet.urjc.es/mailman/listinfo/linux-streams

-- 
Brian F. G. Bidulock    � The reasonable man adapts himself to the �
[EMAIL PROTECTED]    � world; the unreasonable one persists in  �
http://www.openss7.org/ � trying  to adapt the  world  to himself. �
                        � Therefore  all  progress  depends on the �
                        � unreasonable man. -- George Bernard Shaw �

_______________________________________________
Linux-streams mailing list
[EMAIL PROTECTED]
http://gsyc.escet.urjc.es/mailman/listinfo/linux-streams

Reply via email to