context-switch

How to properly use TSX-NI (both HLE and RTM) when threads might switch cores?

和自甴很熟 提交于 2020-06-27 11:55:46
问题 It seems that Intel's Transactional Synchronization Extensions (TSX-NI) work on a per-CPU basis. This applies to both the _InterlockedXxx_HLE{Acquire,Release} Hardware Lock Elision functions (HLE), as well as for the _xbegin / _xend /etc. Restricted Transactional Memory (RTM) functions. What is the "proper" way to use these functions on multi-core systems? Given their correctness guarantees, I assume I only need to be worried about performance here. So, how should I structure & write my code

Is processor cache flushed during context switch in multicore?

倾然丶 夕夏残阳落幕 提交于 2020-03-18 17:38:37
问题 Recently, I discussed why there is a volatile mark at seq in Java Actors demo @volatile private var seq = 0L private def nextSeq: Long = { val next = seq seq += 1 next } One answer was that threads can be migrated and variables lost (other cores will have incoherent values in their private caches). But, you not normally mark every variable with volatile to enable multicore execution. So, cores must flush the caches whenever context is switched. But, I cannot find this statement pronounced

Monitoring pthread context switching

孤街浪徒 提交于 2019-12-29 09:15:10
问题 I would like to monitor the the context switching behavior in a multi-threaded pthread application. In other RTOSes(Micro C OS) I have been able to register a context switch callback for each thread in the application, and then log (or toggle a gpio) and watch the thread context switching in real time. This was a valuable tool for debugging the real time behavior and interaction of the multiple threads. My current environment is embedded linux utilizing the pthread api. Is there a way to

Win32: Atomic Execution of Code Block

天涯浪子 提交于 2019-12-24 10:38:22
问题 I have two system calls GetSystemTime() and GetThreadTimes() that I need to calculate the CPU utilization by a given Win32 thread. For the sake of accuracy, I need to ensure that both GetSystemTime() and GetThreadTimes() are executed atomically; i.e. there should be no context switch in between a call to GetSystemTime() & GetThreadTimes(). The reason is that occasionally I end up with a percentage of over 100% (~ 1 in 500). How can I ensure an atomic execution of the 2 function calls? Thanks,

how to understand the function of “__swtich_ to” for contex-switch in the ARM linux

僤鯓⒐⒋嵵緔 提交于 2019-12-23 04:55:28
问题 I am trying to understand how the context switch of linux works which is based on the ARM. So i want to understand following codes. ENTRY(__switch_to) add ip, r1, #TI_CPU_SAVE ldr r3, [r2, #TI_TP_VALUE] stmia ip!, {r4 - sl, fp, sp, lr} @ Store most regs on stack ldr r6, [r2, #TI_CPU_DOMAIN] strex r5, r4, [ip] @ Clear exclusive monitor mcr p15, 0, r3, c13, c0, 3 @ set TLS register mov r4, #0xffff0fff str r3, [r4, #-15] @ TLS val at 0xffff0ff0 mcr p15, 0, r6, c3, c0, 0 @ Set domain register mov

Returning from kernel mode to user mode

≯℡__Kan透↙ 提交于 2019-12-21 06:24:29
问题 I'm a bit confused about the understanding of a mode switch in Unix kernel. I give my understanding here and open it for discussion/correction. While transitioning from user mode to kernel mode, the processor makes a switch between the per-process-user-stack and the per-process-kernel-stack. Then the user-per-process stack segment selector and stack pointer is stored in the kernel stack and then the eip instruction pointer (return address at user mode) and other hardware registers are pushed

Storing and retrieving process control block

北城余情 提交于 2019-12-20 10:20:32
问题 When a process is in execution, the contents of the PCB (which is in kernel memory space?) are loaded onto the CPU registers, and status registers , kernel stack pointers , user stack pointers , etc. When there is a context switch to another process, the current "context" is stored back in the PCB and a switch is made to the new PCB. Now when the kernel wants to bring back this PCB back into "context", how does it find this PCB, which is in the memory now? What information helps the kernel in

Getting a number of context switches for a process / thread

大憨熊 提交于 2019-12-19 11:35:55
问题 Out of curiosity I want to know how many times my program was context switched by the OS. Like all the registers were saved and the control was passed to another process or thread, and then after some time everything was restored and we continue as it never happened. Does the system maintain such a number somewhere or is there a sort of hack or whatever? I am on Linux in particular but I am interested about other systems as well. 回答1: Well, let's examine the case. Linux type O/S keeps these

Getting a number of context switches for a process / thread

落花浮王杯 提交于 2019-12-19 11:35:41
问题 Out of curiosity I want to know how many times my program was context switched by the OS. Like all the registers were saved and the control was passed to another process or thread, and then after some time everything was restored and we continue as it never happened. Does the system maintain such a number somewhere or is there a sort of hack or whatever? I am on Linux in particular but I am interested about other systems as well. 回答1: Well, let's examine the case. Linux type O/S keeps these

Creating a custom JSON response object with Zend Action Helper ContextSwitch

删除回忆录丶 提交于 2019-12-18 13:19:17
问题 I normally append an encoded json object to the response body, however I now have a situation that warrants using the ContextSwitch action helper. I have a Zend_Form that requires three different response contexts: html - Render the form as normal html within a layout. html-partial - An ajax "get" request that renders just the form as html. json - An ajax "post" request that returns any form valiation error messages. For each context I have 3 view scripts. Although the two html contexts could