CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  进程/线程/DLL

阻塞的线程很多时为何会发生死锁?急!(我是新用户,只有给50分的权利,Sorry!)

楼主yehong()2000-03-02 10:32:00 在 VC/MFC / 进程/线程/DLL 提问

在驱动程序中,有一段处理硬盘I/O的非共享程序(较长,执行时间  
  大约在10到500ms,在该段程序的开端采用了互斥,一般情况下工作  
  正常。但在频繁的硬盘读写期间(例如,在Windows98里拷贝大量文件),  
  鼠标响应会越来越慢,直至完全停止响应。估计是由于阻塞的线程太多  
  造成系统死锁。为什么会这样呢?还是有其他原因?应如何解决此问题,  
  还盼高手们帮帮我!急!急!! 问题点数:50、回复次数:7Top

1 楼blaise()回复于 2000-03-02 12:16:00 得分 0

post   your   codeTop

2 楼deepwater()回复于 2000-03-02 12:29:00 得分 0

I   once   had   the   same   experiance  
  I   guess   if   u   run   your   progamm   on   NT   it   will   be   OK,your   trouble   on   95/98   attributes   to   the   implmentation   of   95/98   's   multithread   -   If   one   thread   of   a   process   is   reading/writing   hard   disk,the   other   processes   or   threads   will   not   get   CPU   time   unless   the   reading/writing   is   finished.  
  One   solution   which   I   took   :   Sleep   for   100~200   ms   in   your   thread   which   reads   or   writes   hard   disk  
   
  Tell   me   your   result   pleaseTop

3 楼deepwater()回复于 2000-03-02 12:34:00 得分 0

Increase   your   buffer   fo   reading/writing,thus   decrease   the   times   of   reading/writing   hard   disk.  
   
  In   my   last   project,I   used   the   two   methodsTop

4 楼yehong()回复于 2000-03-02 20:53:00 得分 0

致deepwater:我试过了,还是不行。我试着用提升优先级的办法,情况好一些,不是每次都死。大概有一半的机会不死。Top

5 楼yehong()回复于 2000-03-02 21:55:00 得分 0

致blaise:  
  这是出问题部分的代码:  
   
  ;code   in   initializing   procedure  
  ...  
                  ;Create   mutex,   if   failure,   abort   resident  
                  push         ecx  
                  push         edx  
                  VmmCall   _CreateMutex,   <   0,   MUTEX_MUST_COMPLETE   >  
                  pop           edx  
                  pop           ecx  
                  or             eax,   eax  
                  mov           dMutex,   eax  
                  mov           eax,   ERROR_CREATE_MUTEX  
                  jz             lVSD_ret_CY  
  ...  
   
  ;==============================================================================  
  ;  
  ;   Gate32_Write_Handler()   -   Handle   writing   routine   for   commands    
  ;  
  ;   Entry:   ebx   is   IOP  
  ;   Exit:     al   set   to   0   to   indicate   calldown,   set   to   1   indication   callback  
  ;                 al   set   to   2   to   indicate   return   without   calldown   or   callback  
  ;  
  ;   Destroys:           eax  
  ;  
  ;==============================================================================  
  beginproc               Gate32_Write_Handler  
   
                  AssertIOP   (ebx)  
   
                  push         edi  
                  VmmCall   Get_Cur_Thread_Handle ;use   current   thread   handle   as   reenter   flag   (dInterFlag)  
                  cmp           edi,   dInterFlag ;if   it's   reenter?  
                  pop           edi  
   
  xor eax,   eax  
                  jz             lGWH_ret ;it's   reenter,   return   to   calldown  
   
                  ;   enter   mutex  
                  push         eax  
                  push         ecx  
                  push         edx  
                  VmmCall   _EnterMutex,   <dMutex,   0>  
                  pop           edx  
                  pop           ecx  
                  pop           eax  
   
                  ;   set   current   thread   handle   to   dInterFlag  
                  push         edi  
                  VmmCall   Get_Cur_Thread_Handle  
                  mov           dInterFlag,   edi  
                  pop           edi  
   
                  Call         Prv_Write_Handler ;该过程处理硬盘写操作,内部读写请求较多,耗时约10-500ms  
                  mov           dInterFlag,           0 ;clear   reenter   flag  
   
                  push         eax  
                  push         dMutex  
                  VmmCall   _LeaveMutex  
                  add           esp,   4  
                  pop           eax  
   
  lGWH_ret:  
                  ret  
   
  endproc                   Gate32_Write_Handler  
  Top

6 楼netmare()回复于 2000-03-02 23:25:00 得分 50

xor   eax,   eax  
  jz   lGWH_ret   ;it's   reenter,   return   to   calldown  
  这不对吧,这等于jmp   lGWH_ret  
  Top

7 楼yehong()回复于 2000-03-03 09:34:00 得分 0

哦,对了,谢谢netmare,这里本是mov   eax,   0Top

相关问题

  • 线程死锁
  • 求助,线程死锁
  • TThread线程死锁问题
  • 关于阻塞和死锁的问题
  • oracle多线程死锁问题,散分~~~~~~~~
  • 多线程导致fopen()调用阻塞???
  • 求 经典的线程池代码(考虑到线程泄露和死锁的)
  • 关于dllmain中的创建新线程,然后...导致死锁
  • Java 多线程中的死锁问题,数据竞争所致?
  • 线程进入阻塞时,线程会不会让出CPU?

关键词

  • 硬盘
  • dinterflag
  • vmmcall
  • calldown
  • reenter
  • lgwh
  • pop
  • eax
  • gate32
  • push

得分解答快速导航

  • 帖主:yehong
  • netmare

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo