内核在收到信号时获取堆栈
我编写读取器和写入器,其中内核必须在它们和块写入器之间同步,
当我在队列中等待时,已经读取消息的块写入器收到信号,因此我执行以下操作
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你在哪里唤醒等待队列?
您应该在某个地方调用
wake_up(readWaitQ1);
。将isExistWriter
设置为 true 后即可实现。Where are you waking up the wait queue?
You should be calling
wake_up(readWaitQ1);
somewhere. Possible after you setisExistWriter
to true.