内核在收到信号时获取堆栈

发布于 2024-09-05 08:54:46 字数 1371 浏览 3 评论 0原文

我编写读取器和写入器,其中内核必须在它们和块写入器之间同步,

当我在队列中等待时,已经读取消息的块写入器收到信号,因此我执行以下操作

while (i_Allready_Read(myf) == ALLREADY_READ || isExistWriter == false )
//while (!(i_Allready_Read(aliveProc,current->pid)))
{
    int i, is_sig = 0;
    printk(KERN_INFO "\n\n*****entered set in read ******\n\n" );
    if (i_Allready_Read(myf) == ALLREADY_READ )
        wait_event_interruptible (readWaitQ1, !i_Allready_Read(myf));
    else
        wait_event_interruptible (readWaitQ1, isExistWriter);

    //printk(KERN_INFO "Read Wakeup %d\n",current->pid);

    for (i = 0; i < _NSIG_WORDS && !is_sig; i++)
    {
        is_sig = current->pending.signal.sig[i] & ~current->blocked.sig[i];
    }

    if (is_sig)
    {
        handledClose(myf);
        module_put (THIS_MODULE);
        return -EINTR;
     }
   }
   return 0;//success

}

inline void handledClose(struct file *myf)//v

{ /* *如果我们关闭作家其他作家 *将能够进入许可者 */

if (myf == writerpid )
{
    isExistWriter = DOESNT_EXIST;
    //printk(KERN_INFO "procfs_close : this is pid that just closed %d \n", writerpid);
}
/*
 *else its a reader so our numofreaders
 *need to decremented
*/
else
{
    removeFromArr(myf);
    numOfReaders--;
}

}

而我的 close 没有执行任何操作...

我做错了什么?

i write readers and writers where the kernel have to syncronize between them and block writer who already read a massage

when i am in the queue waiting I get signal so I do the fallowing

while (i_Allready_Read(myf) == ALLREADY_READ || isExistWriter == false )
//while (!(i_Allready_Read(aliveProc,current->pid)))
{
    int i, is_sig = 0;
    printk(KERN_INFO "\n\n*****entered set in read ******\n\n" );
    if (i_Allready_Read(myf) == ALLREADY_READ )
        wait_event_interruptible (readWaitQ1, !i_Allready_Read(myf));
    else
        wait_event_interruptible (readWaitQ1, isExistWriter);

    //printk(KERN_INFO "Read Wakeup %d\n",current->pid);

    for (i = 0; i < _NSIG_WORDS && !is_sig; i++)
    {
        is_sig = current->pending.signal.sig[i] & ~current->blocked.sig[i];
    }

    if (is_sig)
    {
        handledClose(myf);
        module_put (THIS_MODULE);
        return -EINTR;
     }
   }
   return 0;//success

}

inline void handledClose(struct file *myf)//v

{
/*
*if we close the writer other writer
*would be able to enter to permissiones
*/

if (myf == writerpid )
{
    isExistWriter = DOESNT_EXIST;
    //printk(KERN_INFO "procfs_close : this is pid that just closed %d \n", writerpid);
}
/*
 *else its a reader so our numofreaders
 *need to decremented
*/
else
{
    removeFromArr(myf);
    numOfReaders--;
}

}

and my close does nothing ...

what did i do wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花伊自在美 2024-09-12 08:54:46

你在哪里唤醒等待队列?

您应该在某个地方调用 wake_up(readWaitQ1); 。将 isExistWriter 设置为 true 后即可实现。

Where are you waking up the wait queue?

You should be calling wake_up(readWaitQ1); somewhere. Possible after you set isExistWriter to true.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文