自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 收藏
  • 关注

原创 给内核模块传参 并导出符号

module_param(name, type, perm)这个宏用来给内核模块传参数,其中参数类型有byte,short,ushort,int,uint,long,ulong,charp,bool,invbool* Standard types are: * byte, short, ushort, int, uint, long, ulong * charp: a character pointer * bool: a bool, values 0/1, y/n, Y/N...

2021-04-10 21:18:15 129

原创 两个线程同时使用两个互斥锁访问临界资源,无死锁

思路与qt中那个多线程中的死锁类似,链接如下:https://blog.csdn.net/weixin_47564352/article/details/115019008#include<stdio.h>#include <pthread.h>#include <unistd.h>#include <stdlib.h>pthread_mutex_t mutex1;pthread_mutex_t mutex2;void* threa.

2021-04-08 22:36:50 346 1

原创 智能指针类模板

设计要点:1、同一片内存空间只能有一个指针指向2、指针生命周期结束时自动释放堆空间#ifndef HEAPARRAY_H#define HEAPARRAY_Htemplate <typename T>class SmartPointer{ T* m_pointer;public: SmartPointer(T* p=NULL); SmartPointer(const SmartPointer<T>& obj); Sm.

2021-04-07 22:33:27 94

原创 堆数组类模板

使用二阶构造申请内存资源,第一阶段为HeapArray<T>* HeapArray<T>::newInstance(int len)这是与资源申请无关的操作,给数组申请内存资源放在第二阶段bool HeapArray<T>::construct()T& operator[](int index);重载数组访问操作符,试对象能想数组那样访问内存空间,非const对象使用这个数组访问操作符T operator[] (int index) const;con

2021-04-07 09:14:18 104

原创 大华相机中的一个模板嵌套

CSingleDisplayDlg::CSingleDisplayDlg(CWnd* pParent /*=NULL*/) : CDialog(CSingleDisplayDlg::IDD, pParent) , _connected(false) , _isGrabbing(false) , _bRunning(false) , _frameCnt(0) , _frameCtrl(false) , _maxFrameCnt(0) , _devListDlg(NULL) , _displ.

2021-04-06 08:57:26 249

原创 Makefile 自动生成依赖关系并加载依赖文件

.PHONY: all clean EXE := app.outDIR_OBJS := objsDIR_EXES := exesDIR_DEPS := depsDIRS := $(DIR_OBJS) $(DIR_EXES) $(DIR_DEPS)SRCS := $(wildcard *.c)OBJS := $(SRCS:.c=.o)OBJS := $(addprefix $(DIR_OBJS)/, $(OBJS))DEPS := $(SRCS:.c=....

2021-04-05 22:52:15 200

原创 模型与视图简易示例

设计思路:datasource.cpp:从文本文件中读取数据后进行解析(代码中以逗号为分隔符,将数据提取出来),并把数据送给scoreinfo.cpp进行处理,形成数据项,每一项数据项包含编号、名字、成绩scoreinfo.cpp:组织数据,形成数据项,这里的数据项会传给scoreinfomodel.cppscoreinfomodel.cpp:将scoreinfo.cpp中的数据项添加到模型里面去,并将模型与视图相关联widget.cpp:提供上层接口,控制模型与视图的显示,数据的加载与删.

2021-04-05 11:19:44 117

原创 简易登录对话框

//dialog.h#ifndef DIALOG_H#define DIALOG_H#include <QWidget>#include <QDialog>#include <QLabel>#include <QLineEdit>#include <QPushButton>#include <QFormLayout>#include <QString>#include <QMessageBox&.

2021-04-01 20:20:57 101

原创 socket编程

本文参考韦东山嵌入式linux应用编程教学视频//客户端#include <stdio.h>#include <sys/types.h> /* See NOTES */#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <string.h>#include <unistd.h>#d.

2021-03-30 21:21:58 57

原创 布局管理器的嵌套

//widget.h#ifndef WIDGET_H#define WIDGET_H#include <QWidget>#include <QPushButton>#include <QHBoxLayout>#include <QVBoxLayout>#include <QGridLayout>#include <QLabel>#include <QLineEdit>#include <QFo.

2021-03-28 23:33:15 124

原创 逆序打印单向链表

#include <iostream>using namespace std;struct Node{ int val; struct Node* next;};Node* List_Create(){ Node* list = NULL; Node* slider = NULL; for(int i=0; i<5; i++) { struct Node* n = new Node(); .

2021-03-27 11:43:38 70

原创 选择排序 插入排序 冒泡排序 希尔排序

#include <iostream>using namespace std;class sort{private: template <typename T> static void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }public: template <typename T> stati.

2021-03-26 23:06:51 57

原创 模板类中嵌套函数模板、构造函数为模板

#include <iostream>#include <typeinfo>using namespace std;template<typename T1>class Test{public: Test() { cout << "Test()" << endl; } Test(T1 v) { cout << "Test(T1 v)" &lt.

2021-03-25 12:24:38 462

原创 单链表操作

LinkList.h#ifndef _LINKLIST_H#define _LINKLIST_H#include <stdlib.h>struct LinkListNode { struct LinkListNode* next;};struct LinkListHead { struct LinkListNode head; int length;};void LinkList_Init(struct L

2021-03-23 21:36:47 75

原创 linux内核链表

#include <stdio.h>#include <stdlib.h>struct list_head{ struct list_head* prev; struct list_head* next;};struct mylist { struct list_head head; int val;};void __list_add(struct list_head* new, struct list_head* prev, .

2021-03-22 12:34:32 74

原创 inet_ntoa() inet_aton()

int inet_aton(const char *cp, struct in_addr *inp);将形如“192.168.1.1"类型的点分十进制ip转换成二进制,并存放在struct in_addr中192 = 0xc0168 = 0xa81 = 0x01因此转换后的值为0xc0a811char *inet_ntoa(struct in_addr in);将二进制的ip转成点分十进制形式,转换结果作为返回值struct hostent *gethostbyadd..

2021-03-20 22:20:12 2575

原创 多线程中的死锁

#include <QCoreApplication>#include <QThread>#include <QMutex>#include <QDebug>QMutex mutex1;QMutex mutex2;class ThreadA : public QThread{protected: void run() { while(true) { mutex1.lo.

2021-03-20 00:43:36 111

原创 多线程与界面组件通信

思路:在子线程中使用postEvent()发送自定义的事件类对象,在主线程中更改界面状态//stringEvent.h 自定义事件类#ifndef STRINGEVENT_H#define STRINGEVENT_H#include <QEvent>#include <QString>class stringEvent : public QEvent{private: QString m_data;public: const static

2020-12-26 20:19:33 131 1

原创 创建一个线程

//mythread.h#ifndef MYTHREAD_H#define MYTHREAD_H#include <QObject>#include <QDebug>#include <QThread>class MyThread : public QObject{ Q_OBJECTprivate: int val; QThread m_thread;public: explicit MyThread(QObject.

2020-12-26 12:07:15 100

原创 FreeRTO之任务切换

xTaskCreateStatic( ) rvInitialiseNewTask( ) pxTopOfStack = pxNewTCB->pxStack + ( ulStackDepth - ( uint32_t ) 1 ); pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters ); StackType_t *pxPor...

2020-11-22 14:40:48 569

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除