当前位置:网站首页>Understanding of CPU buffer line
Understanding of CPU buffer line
2022-07-03 13:00:00 【aslia】
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace Buff
{
// [StructLayout(LayoutKind.Explicit, Size = 120)]
// class Tclass
// {
// [FieldOffset(56)]
// public long x = 0l;
// }
class Tclass
{
public long x = 0l;
}
internal class T01_CacheLinePadding
{
public static Tclass[] arr = new Tclass[2];
public static long COUNT = 10_0000_0000l;
public static System.DateTime startTime;
public static void Main(string[] args)
{
arr[0] = new Tclass();
arr[1] = new Tclass();
startTime = System.DateTime.Now;
//Run();
RunOne();
}
public static void RunOne()
{
for (int j = 0; j < COUNT; j++)
{
arr[0].x = j;
arr[1].x = j;
}
DateTime dt2 = System.DateTime.Now;
TimeSpan ts = dt2.Subtract(startTime);
Console.WriteLine(string.Format(" At present t1 Time for :{0}",ts.TotalMilliseconds));
}
public static void Run()
{
List<ManualResetEvent> list = new List<ManualResetEvent>();
ManualResetEvent mre = new ManualResetEvent(false);
System.Threading.Thread thread = new Thread((o) =>
{
for (int j = 0; j < COUNT; j++)
{
arr[0].x = j;
}
((ManualResetEvent)o).Set();
});
System.Threading.Thread thread1 = new Thread((o) =>
{
for (int j = 0; j < COUNT; j++)
{
arr[1].x = j;
}
((ManualResetEvent)o).Set();
});
list.Add(mre);
thread.Start(mre);
thread1.Start(mre);
WaitHandle.WaitAll(list.ToArray());
DateTime dt2 = System.DateTime.Now;
TimeSpan ts = dt2.Subtract(startTime);
Console.WriteLine(string.Format(" At present t1 Time for :{0}",ts.TotalMilliseconds));
}
}
}边栏推荐
- ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
- 2022-01-27 redis cluster cluster proxy predixy analysis
- [combinatorics] permutation and combination (the combination number of multiple sets | the repetition of all elements is greater than the combination number | the derivation of the combination number
- Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
- 【数据库原理及应用教程(第4版|微课版)陈志泊】【SQLServer2012综合练习】
- 【数据库原理及应用教程(第4版|微课版)陈志泊】【第五章习题】
- 高效能人士的七个习惯
- 剑指 Offer 15. 二进制中1的个数
- 低代码平台国际化多语言(i18n)技术方案
- 【综合题】【数据库原理】
猜你喜欢

最新版盲盒商城thinkphp+uniapp

The latest version of blind box mall thinkphp+uniapp

Social community forum app ultra-high appearance UI interface

Image component in ETS development mode of openharmony application development

01 three solutions to knapsack problem (greedy dynamic programming branch gauge)

并网-低电压穿越与孤岛并存分析

Seven second order ladrc-pll structure design of active disturbance rejection controller

Harmonic current detection based on synchronous coordinate transformation

How to convert a decimal number to binary in swift

【数据库原理及应用教程(第4版|微课版)陈志泊】【第三章习题】
随机推荐
基于Linu开发的项目视频
How to stand out quickly when you are new to the workplace?
4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
[ArcGIS user defined script tool] vector file generates expanded rectangular face elements
Analysis of the influence of voltage loop on PFC system performance
Airflow installation jump pit
Two solutions of leetcode101 symmetric binary tree (recursion and iteration)
Glide 4.6.1 API initial
并网-低电压穿越与孤岛并存分析
Do you feel like you've learned something and forgotten it?
Detailed explanation of the most complete constraintlayout in history
Application of ncnn neural network computing framework in orange school orangepi 3 lts development board
Loan calculator my pressure is high
SSH登录服务器发送提醒
Simple use and precautions of kotlin's array array and set list
C graphical tutorial (Fourth Edition)_ Chapter 20 asynchronous programming: examples - using asynchronous
Xctf mobile--rememberother problem solving
【数据库原理及应用教程(第4版|微课版)陈志泊】【第五章习题】
【Colab】【使用外部数据的7种方法】
C graphical tutorial (Fourth Edition)_ Chapter 17 generic: genericsamplep315