解释Logcat条目:threadid = 8:撤消后仍挂起(sc = 1 dc = 1 s = Y) [英] Interpret Logcat entry: threadid=8: still suspended after undo (sc=1 dc=1 s=Y)

查看:108
本文介绍了解释Logcat条目:threadid = 8:撤消后仍挂起(sc = 1 dc = 1 s = Y)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序启动后,我正在运行大约十个AsyncTask.有时仿真器需要很长时间才能启动这些任务.发生这种情况时,我会在日志猫中看到以下消息:

I am running around ten AsyncTasks after my application starts. Sometimes the emulator takes a long time to start these tasks. When this occurs, I see the following message in the log cat:

D/dalvikvm(1983):threadid = 8:撤消操作后仍处于挂起状态(sc = 1 dc = 1 s = Y)

当仿真器快速执行时,此消息不会出现.奇怪的是,今天这种行为没有任何修改就改变了.由于我已将512mb内存明确分配给仿真器,因此〜5min不再是非常慢,现在为〜5s.在真实的设备上,我永远不会执行得这么慢.

When the emulator executes quickly this message doesn't appear. Strangely, this behavior changed today without any modifications. Since I have explicitly assigned 512mb ram to the emulator, it is no longer extremely slow ~5min, now ~5s. On a real device I never have execution that slow.

我想了解此日志猫消息的含义.我了解到具有指定ID的线程处于挂起状态,并且在此状态下不起作用.但为什么?什么撤消之后? (sc = 1 dc = 1 s = Y)是什么意思?

推荐答案

消息来自dvmSuspendSelf(),当调试器(通过JDWP线程)要求其挂起时,线程将调用该消息.

The message comes from dvmSuspendSelf(), which threads call when the debugger (via the JDWP thread) has asked them to suspend.

它应该工作的方式是(我们"是线程):

The way it's supposed to work is (where "we" are a thread):

  • JDWP要求我们暂停
  • 我们告诉我们我们已经暂停并入睡
  • 最终,调试器将我们唤醒,然后我们恢复运行

VM在条件变量正在等待信号时记录了该消息,但是由于某些原因,我们仍被标记为已暂停.代码说明:

The message is logged when the condition variable the VM is waiting on signals, but for some reason we're still marked as suspended. The code notes:

/*
 * The condition was signaled but we're still suspended.  This
 * can happen if the debugger lets go while a SIGQUIT thread
 * dump event is pending (assuming SignalCatcher was resumed for
 * just long enough to try to grab the thread-suspend lock).
 */

在这种情况下,我们期望当信号到达时我们被意外唤醒(例如,system_server认为存在ANR,因为主线程由于调试器已将其挂起而没有响应),并且如果我们再次循环调试器将有机会清理我们并使我们前进.

The expectation in this case is that we got woken up unexpectedly when a signal arrived (e.g. system_server thinks there's an ANR because the main thread isn't responding because the debugger has suspended it), and if we loop around again the debugger will get a chance to clean us up and set us on our way.

该日志消息将打印self->suspendCount(告诉我们暂停自己多少次),self->dbgSuspendCount(其中多少暂停请求来自调试器)的值,因此我们可以撤消"所有这些值如果调试器断开连接),则self->isSuspended布尔值.

The log message is printing the values of self->suspendCount (how many times have we been told to suspend ourselves), self->dbgSuspendCount (how many of those suspend requests came from the debugger, so we can "undo" all those if the debugger disconnects), and the value of the self->isSuspended boolean.

请注意,姜饼中的"s = Y"标志已消失-线程暂停的工作方式为更改.

Note the "s=Y" flag disappeared in gingerbread -- the way thread suspension works was changed.

这篇关于解释Logcat条目:threadid = 8:撤消后仍挂起(sc = 1 dc = 1 s = Y)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆