摘要: 进程有就绪、运行和阻塞三种状态。 进程三个状态之间转换通过PV操作实现。PV操作是针对信号量的P操作和V操作。 信号量 信号量是最早出现的用来解决进程同步与互斥问题的机制。 信号量(Saphore)由一个值和一个指针组成,指针指向等待该信号量的进程。信号量的值表示相应资源的使用情况。 信号量S>=0 阅读全文
posted @ 2021-05-25 09:43 风不会停息gcc 阅读(1186) 评论(0) 推荐(0)
摘要: 最近在做文件IO读写相关的工作,以前一直对printf、fwrite和c++的write不是特别熟悉,写个随笔记录下。 fprintf int fprintf( FILE *stream, const char *format, ... ); Loads the data from the give 阅读全文
posted @ 2021-05-16 21:51 风不会停息gcc 阅读(575) 评论(0) 推荐(0)
摘要: C语言提供了malloc和free两个系统函数,完成对堆内存的申请和释放,malloc/free是库函数,需要头文件支持。而C++则提供了两个关键字new和delete,需要编译器支持。 1、new和delete C++中,用new和delete动态创建数组或单个对象,new表达式返回指向该新创健对 阅读全文
posted @ 2021-04-26 22:44 风不会停息gcc 阅读(747) 评论(0) 推荐(0)
摘要: std::stringstream::str // stringstream::str #include <string> // std::string #include <iostream> // std::cout #include <sstream> // std::stringstream, 阅读全文
posted @ 2021-04-26 14:53 风不会停息gcc 阅读(3229) 评论(0) 推荐(0)
摘要: 资料来源于:https://en.cppreference.com/w/cpp/algorithm/upper_bound upper_bound()和lower_bound()利用二分查找的方法在有序数组里面进行查找。 upper_bound() template< class ForwardIt 阅读全文
posted @ 2021-03-30 22:30 风不会停息gcc 阅读(612) 评论(0) 推荐(0)
摘要: class UF{ private: vector<int> parent; vector<int> sz; int cnt; public: UF(int n):parent(n), sz(n), cnt(n){ for(int i = 0; i < n; i++) { parent[i] = i 阅读全文
posted @ 2021-01-27 20:05 风不会停息gcc 阅读(59) 评论(0) 推荐(0)
摘要: 树节点定义: typedef struct TreeNode{ int val; TreeNode *left; TreeNode *right; TreeNode(int a):val(a), left(NULL), right(NULL){} }TreeNode; AVL树接口: class A 阅读全文
posted @ 2021-01-27 20:02 风不会停息gcc 阅读(62) 评论(0) 推荐(0)