Linux内核源码分析 -- 同步原语 -- 自旋锁 spinlock_t typedef struct spinlock { union { struct raw_spinlock rlock; #ifdef CONFIG_DEBUG_LOCK_ALLOC # define LOCK_PADSIZ ...
分类:
系统相关 时间:
2020-06-08 00:16:40
阅读次数:
138
Given a binary tree, return the sum of values of nodes with even-valued grandparent. (A grandparent of a node is the parent of its parent, if it exist ...
分类:
其他好文 时间:
2020-06-08 00:15:28
阅读次数:
76
Linux内核源码分析 -- 同步原语 -- 信号量 semaphore 源码位于 include/linux/semaphore struct semaphore { raw_spinlock_t lock; // 保护信号量的自旋锁 unsigned int count; // 现有的资源的数量 ...
分类:
系统相关 时间:
2020-06-07 19:39:35
阅读次数:
105
`package main import ( "fmt" "strconv" "time" ) //生产者结构体 type Productor struct var Chquit = make(chan interface, 2) var Bag = false func main() { fmt. ...
分类:
其他好文 时间:
2020-06-07 15:07:34
阅读次数:
65
一. using System;//001.C#支持哪几个预定义的值类型//002.C#支持哪几种预定义的引用类型namespace _001_homework{ class Program { static void Main(string[] args) { //1.valueType(值类型) ...
分类:
编程语言 时间:
2020-06-07 01:05:10
阅读次数:
70
package main import "fmt" type Dog struct { Name string } func TestStruct() { // 方式1 //var dog Dog //dog.Name = "jj" // 方式2 //dog := Dog{Name:"wang"} ...
分类:
其他好文 时间:
2020-06-06 23:27:52
阅读次数:
94
函数原型: <termios.h> <unistd.h>int tcgetattr(int fd, struct termios* info)//从与fd有关的终端驱动程序中获取当前设置int tcsetattr(int fd, int when, struct termios* info)//从i ...
分类:
其他好文 时间:
2020-06-06 22:00:12
阅读次数:
78
当有多个进程要访问同一个文件的时候,为了防止多进程访问导致的不一致,我们就要考虑进程间的同步问题了。 举例说明:在嵌入式编程中经常会遇到写配置文件的问题,这个时候由于多进程操作就需要跟配置文件加写锁操作。 fcntl是一个非常强大的函数,在这里我们可以使用它来给文件的某一个部分上锁。先来看一下它的声 ...
分类:
其他好文 时间:
2020-06-06 18:14:33
阅读次数:
71
题意:模拟图书馆图书的借用状态。书有三种状态:1在图书馆的书架上,2被接走了,3刚还回来还没有放到书架上。每次有三种操作:1借书,2还书,3把换回来的书放回书架。 思路:思路简单,主要就是map,set的运用比较复杂,还是折腾了挺久 #include<bits/stdc++.h> struct Bo ...
分类:
其他好文 时间:
2020-06-06 13:16:27
阅读次数:
62
一、技术总结 二、参考代码 #include<iostream> #include<vector> #include<queue> using namespace std; struct node{ int h, v; node* L; node* R; }; node* newNode(int v ...
分类:
其他好文 时间:
2020-06-05 22:37:58
阅读次数:
71