当前位置:网站首页>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));
}
}
}边栏推荐
- 【数据库原理及应用教程(第4版|微课版)陈志泊】【第三章习题】
- Kotlin notes - popular knowledge points asterisk (*)
- It feels great to know you learned something, isn‘t it?
- Xctf mobile--app1 problem solving
- The best shortcut is no shortcut
- mysqlbetween实现选取介于两个值之间的数据范围
- 有限状态机FSM
- Enter the length of three sides of the triangle through the user, and calculate the area of the triangle, where the length is a real number
- 低代码平台国际化多语言(i18n)技术方案
- 我的创作纪念日:五周年
猜你喜欢

Leetcode234 palindrome linked list

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

Glide question you cannot start a load for a destroyed activity

ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍

基于同步坐标变换的谐波电流检测

Sitescms v3.1.0 release, launch wechat applet

电压环对 PFC 系统性能影响分析

sitesCMS v3.1.0发布,上线微信小程序

Quick learning 1.8 front and rear interfaces

Brief introduction to mvcc
随机推荐
【数据库原理及应用教程(第4版|微课版)陈志泊】【第六章习题】
ORM use of node -serialize
Differences and connections between final and static
Xctf mobile--rememberother problem solving
C graphical tutorial (Fourth Edition)_ Chapter 17 generic: genericsamplep315
01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
The upward and downward transformation of polymorphism
Swift5.7 extend some to generic parameters
关于CPU缓冲行的理解
Ten workplace rules
Xctf mobile--app2 problem solving
When the R language output rmarkdown is in other formats (such as PDF), an error is reported, latex failed to compile stocks Tex. solution
The foreground uses RSA asymmetric security to encrypt user information
C graphical tutorial (Fourth Edition)_ Chapter 20 asynchronous programming: examples - using asynchronous
4. 无线体内纳米网:电磁传播模型和传感器部署要点
Project video based on Linu development
Export the entire Oracle Database
[problem exploration and solution of one or more filters or listeners failing to start]
Application of ncnn neural network computing framework in orange school orangepi 3 lts development board
【R】【密度聚类、层次聚类、期望最大化聚类】