原创 linux 多線程信號量(生產者消費者問題)

生產者消費者問題 這是一個非常經典的多線程題目,題目大意如下:有一個生產者在生產產品,這些產品將提供給若干個消費者去消費,爲了使生產者和消費者能併發執行,在兩者之間設置一個有多個緩衝區的緩衝池,生產者將它生產的產品放入一個緩衝

原创 mysql 特徵和隔離級別概念

事物特性 原子性(Atomicity) 原子性是指事務是一個不可分割的工作單位,事務中的操作要麼都發生,要麼都不發生。 一致性(Consistency) 事務必須使數據庫從一個一致性狀態變換到另外一個一致性狀態 隔離性(Isol

原创 linux c socket多進程服務端

server_process.c #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types

原创 mysql存儲過程基礎知識

cursor遊標應用 select * from tbl_student0101; drop procedure if exists crt_std; delimiter // create procedure crt_std(

原创 mysql 存儲過程創建一年表

drop PROCEDURE if EXISTS create_table; delimiter // create procedure create_table() begin declare date_end

原创 mysql count聚合函數性能

count(*)、count(主鍵id) 和 count(1) 都表示返回滿足條件的結果集的總行數; 而count(字段),則表示返回滿足條件的數據行裏面,參數“字段”不爲 NULL 的總個數。 性能差別 server 層要什麼

原创 C++ 頂層const與底層const

1.頂層const:指代指針是一個常量 2.底層const:指代指針指向的對象是一個常量。 int i = 0; int *const p1 = &i;//不能改變p1的值,這是一個頂層const,符合第一點 const int

原创 linux c epoll

#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys

原创 linux C不用庫函數實現字符串轉數字

1.計算字符串長度; 2.計算10的n次方; #include <stdio.h> #include <string.h> int get_power(int n) { int i =0 ; int sum = 10; i

原创 ubuntu版本下載 阿里雲

http://mirrors.aliyun.com/ubuntu-releases/

原创 linux 結構體對齊大小計算

1.對齊大小,可以設置,若對齊大於結構體中最大類型變量,則按照結構體中最大類型長度進行對齊; 2.類型變量小於對齊大小,則需要進行補齊 #include <stdio.h> typedef struct{ int a; do

原创 一個鏈表不知道頭結點,有一個指針指向其中一個結點,請問如何刪除這個指針指向的結點。

1.若果知道鏈表頭結點,一般都是通過遍歷找到該結點p和前一個結點q後,斷開p結點,連接q->next=p->next,釋放free§; 2.沒有給出頭結點,但將p後一節點q中的數據賦值給p結點,再釋放q結點,也相當於刪除p結點 N

原创 UE C代碼格式化astyle配置

首先下載最新的astyle,因爲ue自帶的astyle版本太老,不支持空格、中文名等。 解壓縮後得到 astyle.exe, 將之拷貝到 ue目錄的gnu目錄下面,覆蓋原來的astyle.exe 打開ue, 選擇“菜單

原创 mysql存儲過程

cursor遊標應用 select * from tbl_student0101; drop procedure if exists crt_std; delimiter // create procedure crt_std(

原创 linux 多線程面試題

編寫一個程序,開啓3個線程,這3個線程的ID分別爲A、B、C,每個線程將自己的ID在屏幕上打印10遍,要求輸出結果必須按ABC的順序顯示;如:ABCABC…依次遞推。 使用pthread_join進行阻塞,等對應的id線程運行結