当前位置:网站首页>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));
}
}
}边栏推荐
- Glide question you cannot start a load for a destroyed activity
- ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
- Leetcode234 palindrome linked list
- The upward and downward transformation of polymorphism
- 剑指 Offer 14- I. 剪绳子
- The foreground uses RSA asymmetric security to encrypt user information
- Sword finger offer14 the easiest way to cut rope
- Redhat5 installing socket5 proxy server
- Express abstract classes and methods
- Export the entire Oracle Database
猜你喜欢

Low code platform international multilingual (I18N) technical solution

Analysis of a music player Login Protocol

最新版盲盒商城thinkphp+uniapp

Swift bit operation exercise
![[review questions of database principles]](/img/c3/81d192a40bcc4f5d72fcbe76c708bb.png)
[review questions of database principles]

Powerful avatar making artifact wechat applet

Brief introduction to mvcc

【Colab】【使用外部数据的7种方法】

Harmonic current detection based on synchronous coordinate transformation

Detailed explanation of the most complete constraintlayout in history
随机推荐
Dojo tutorials:getting started with deferrals source code and example execution summary
Differences and connections between final and static
Seven second order ladrc-pll structure design of active disturbance rejection controller
Cache penetration and bloom filter
【数据库原理及应用教程(第4版|微课版)陈志泊】【第七章习题】
对业务的一些思考
How to get user location in wechat applet?
Harmonic current detection based on synchronous coordinate transformation
[exercise 7] [Database Principle]
4. 无线体内纳米网:电磁传播模型和传感器部署要点
01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
Image component in ETS development mode of openharmony application development
Attack and defense world mobile--ph0en1x-100
解决 System has not been booted with systemd as init system (PID 1). Can‘t operate.
Using swift language features, write a pseudo-random number generator casually
基于同步坐标变换的谐波电流检测
Airflow installation jump pit
C graphical tutorial (Fourth Edition)_ Chapter 20 asynchronous programming: examples - using asynchronous
2022-01-27 use liquibase to manage MySQL execution version
The solution to change the USB flash disk into a space of only 2m