When I'm running wmic query via command line, I'm detected a line with ThreadCount value.
I don't know about the meaning of ThreadCount.
I'm running this wmic query:
wmic process where (Caption like '%explorer%') get * /format:list
Output of above query:
Caption=explorer.exe
CommandLine=C:\Windows\Explorer.EXE
CreationClassName=Win32_Process
CreationDate=20140725092933.908032+330
CSCreationClassName=Win32_ComputerSystem
CSName=DIGITALFOX
Description=explorer.exe
ExecutablePath=C:\Windows\Explorer.EXE
ExecutionState=
Handle=1820
HandleCount=856
InstallDate=
KernelModeTime=50388323
MaximumWorkingSetSize=1380
MinimumWorkingSetSize=200
Name=explorer.exe
OSCreationClassName=Win32_OperatingSystem
OSName=Microsoft Windows 7 Ultimate |C:\Windows|\Device\Harddisk0\Partition2
OtherOperationCount=90378
OtherTransferCount=2089300
PageFaults=63847
PageFileUsage=32724
ParentProcessId=1776
PeakPageFileUsage=70672
PeakVirtualSize=284794880
PeakWorkingSetSize=42564
Priority=8
PrivatePageCount=33509376
ProcessId=1820
QuotaNonPagedPoolUsage=48
QuotaPagedPoolUsage=388
QuotaPeakNonPagedPoolUsage=53
QuotaPeakPagedPoolUsage=490
ReadOperationCount=1543
ReadTransferCount=4529679
SessionId=1
Status=
TerminationDate=
ThreadCount=30
UserModeTime=34008218
VirtualSize=235257856
WindowsVersion=6.1.7600
WorkingSetSize=33030144
WriteOperationCount=6
WriteTransferCount=696
What is the meaning of ThreadCount in above data?
About Processes and Threads
Each process provides the resources needed to execute a program. A process has a virtual address space, executable code, open handles to system objects, a security context, a unique process identifier, environment variables, a priority class, minimum and maximum working set sizes, and at least one thread of execution. Each process is started with a single thread, often called the primary thread, but can create additional threads from any of its threads.
A thread is the entity within a process that can be scheduled for execution. All threads of a process share its virtual address space and system resources. In addition, each thread maintains exception handlers, a scheduling priority, thread local storage, a unique thread identifier, and a set of structures the system will use to save the thread context until it is scheduled. The thread context includes the thread's set of machine registers, the kernel stack, a thread environment block, and a user stack in the address space of the thread's process. Threads can also have their own security context, which can be used for impersonating clients.
ms-help://MS.MSSDK.1033/MS.WinSDK.1033/dllproc/base/about_processes_and_threads.htm
In this the Threadcount is the No of threads that process is currently using.
In your situation the process explorer is using 30 threads.
Thread count is used for avoiding orphan threads so before closing the process thread count should be zero.
Related
I have some Thread Groups with Startup delay. This delay is needed in the actual execution. But while validating the Thread Group before the actual run, I don't want to wait for that delay and wants to run that Thread group immediately.
How to override the StartDelay timings for Thread Group. So that I can directly execute that command without doing any changes for testing the Thread group.
You can set Thread group's startup delay using property, for example
${__P(startupDelay , 1000}
This way delay will be 1000, unless you add startupDelay JMeter property which override (with 0 for example)
Since JMeter 3.0 there is Validate entry in the Thread Group context menu:
According to the documentation:
Validation Mode:
This mode enables rapid validation of a Thread Group by running it with 1 thread, 1 iteration, no timers and no Startup delay set to 0. Behaviour can be modified with some properties by setting in user.properties:
testplan_validation.nb_threads_per_thread_group : Number of threads to use to validate a Thread Group, by default 1
testplan_validation.ignore_timers : Ignore timers when validating the thread group of plan, by default 1
testplan_validation.number_iterations : Number of iterations to use to validate a Thread Group
testplan_validation.tpc_force_100_pct : Whether to force Throughput Controller in percentage mode to run as if percentage was 100%. Defaults to false
So you can run your Thread Group using Validate menu entry and it will ignore any startup delay and if defaults are not suitable for you they can be overriden via relevant JMeter Properties
I am working on CPU-IDLE in Linux. I have the question who spawns idle tasks per CPU core i.e. if there are 4 arm CPU cores, who spawns the per CPU idle task? Where the code for the same is located for creating idle tasks? I understand that start_kernel in init/main.c is run by init process.
Can someone please point out the location of the code where the idle tasks are created per CPU core for CPU idle?
Regards,
Snu
Using the 5.3 kernel as a reference:
start_kernel() in "init/main.c" calls arch_call_rest_init().
arch_call_rest_init() in "init/main.c" calls rest_init().
rest_init() in "init/main.c" calls kernel_thread() to create the init process with kernel_init as the thread function.
kernel_init() in "init/main.c" calls kernel_init_freeable().
kernel_init_freeable() in "init/main.c" calls smp_init().
smp_init() in "kernel/smp.c" calls idle_threads_init().
idle_threads_init() in "kernel/smpboot.c" calls idle_init(cpu) for each CPU apart from the boot CPU.
idle_cpu(cpu) in "kernel/smpboot.c" calls fork_idle(cpu).
fork_idle(cpu) in "kernel/fork.c" clones the init process thread and calls init_idle(task, cpu).
init_idle(task, cpu) in "kernel/sched/core.c" sets up the idle thread for the CPU.
We have used hystrix - circuit breaker pattern [library] in our one of the module.
usecase is:- we are polling 16 number of messages from kafka and processing them using pararllel stream,so, for each message in workflow it takes 3 rest calls which are protected by hystric command. Now, issue is when I try to run my single instance then CPU shows spikes and thread dump shows many threads in waiting state for all the 3 commands. Like below:-
Omitted thread name but assume all all thread pools it shows same thing:-
Thread Pool-7" #82
Thread State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x000000004cee2312> (a java.util.concurrent.SynchronousQueue$TransferStack)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:458)
at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:362)
at java.util.concurrent.SynchronousQueue.take(SynchronousQueue.java:924)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Could you please help me in fine tuning application and thread pool parameters?
what I am missing here?
The default isolation strategy of Hystrix is threadpool and its default size is just 10. It means that only 10 REST calls can be running at the same time in your case.
First, try to increase the below default property to big one.
hystrix.threadpool.default.coreSize=1000 # default is 10
If it works, adjust the value to the proper one.
default can be replaced with the proper HystrixThreadPoolKey for each thread pool.
If you are using Semaphore isolation strategy, try to increase the below one.
hystrix.command.default.execution.isolation.semaphore.maxConcurrentRequests=1000
Above one's default is also just 10. default can be replaced with HystrixCommandKey name for each semaphore.
Updated
To choose the isolation strategy, you can use the below property.
hystrix.command.default.execution.isolation.strategy=THREAD or SEMAPHORE
default can be replaced with HystrixCommandKey. It means that you can assign different strategy for each hystrix command.
I have a worker role that runs a number of parallel background workers. These workers run tasks that last from one minute to 5 hours and use quite a lot of memory.
I would like to delay the start of a new worker by testing the current level of memory consumption. Something like this:
while (memoryAvailable < 50%) {
Thread.Sleep( 1000 * 60 * 10 ); // 10 minutes
}
Can I test for available memory within a worker role?
Also, can I automate a reboot of the instance if memory drops below a certain amount?
Since your worker role instances are Windows Server 2012, you can just set up an appropriate perf counter during role startup ( OnStart() ) with whichever pertinent Memory counters you're interested in, and set up a task to observe the perf counter periodically. When available memory drops below your threshold (or committed bytes exceeds your threshold), you can easily recycle the role instance:
RoleEnvironment.RequestRecycle();
How do I check to see if a Win32 thread is running or in suspended state?
I can't find any Win32 API which gives the state of a thread. So how do I get the thread state?
I think - originally - this information was not provided because any API that provided this info would be misleading and useless.
Consider two possible cases - the current thread has suspended the thread-of-interest. Code in the current thread knows about the suspended state and should be able to share it so theres no need for the kernel team to add an API.
The 2nd case, some other / a 3rd thread in the system has suspended the thread of interest (and theres no way to track which thread that was). Now you have a race condition - that other thread could, at any time - unsuspend the thread of interest and the information gleaned from the API is useless - you have a value indicating the thread is suspended when it is in fact, not.
Moral of the story - if you want to know that a thread is suspended - suspend it: The return value from SuspendThread is the previous suspend count of the thread. And now you DO know something useful - The thread WAS AND STILL IS suspended - which is useful. Or that it WASN't (but now is) suspended. Either way, the thread's state is now deterministically known so you can in theory make some intelligent choices based on that - whether to ResumeThread, or keep it suspended.
You can get this information by calling NtQuerySystemInformation() with the value for SystemProcessesAndThreadsInformation (integer value 5).
If you want an example of what you can do with this information take a look at Thread Status Monitor.
WMI's Win32_Thread class has a ThreadState property, where 5: "Suspended Blocked" and 6:Suspended Ready.
You will need the Thread's Id to get the right instance directly (the WMI object's Handle property is the thread id).
EDIT: Given this PowerShell query:
gwmi win32_thread | group ThreadState
gives
Count Name Group
----- ---- -----
6 2 {, , , ...}
966 5 {, , , ...}
WMI has a different definition of "Suspended" to Win32.
In Windows 7, you can use QueryUmsThreadInformation. (UMS stands for User mode scheduling).
See here for UmsThreadIsSuspended.
you could get thread suspend count with code like this:
DWORD GetThreadSuspendCount(HANDLE hThread) {
DWORD dwSuspendCount = SuspendThread(hThread);
ResumeThread(hThread);
return dwSuspendCount;
}
but, as already said - it is not accurate.
Moreover, suspending a thread is evil.
YES: it IS possible to get the thread state and determine if it is suspended.
And NO: You don't need Windows 7 to do that.
I published my working class here on Stackoverflow: How to get thread state (e.g. suspended), memory + CPU usage, start time, priority, etc
This class requires Windows 2000 or higher.
I think the state here is referred to as
If thread is in thread proc , doing some processing Or
Waiting for event
This can be taken care of by using variable which can tell that if a thread is actually running or waiting for event to happen.
These scenarios appear when considering threadpools, having some n threads and based on each thread running status , tasks can be assigned to idle threads.