linux 執行緒 例程 使用方法

2021-06-05 21:08:22 字數 730 閱讀 2858

01 #include

02#include

03 #include

04#include //sched_setscheduler()

0506 void thread(void)

07    

22     

23 int main(void)

24 33

34     return(0);

35 }

gcc test.c -lpthread

#include

#include

#include

#include

#include //sched_setscheduler()

pthread_mutex_t mutex;

int g_max;

void thread(void)

//pthread_exit(0);

}   

int main(void)

for (i = 0; i < 3; i++)

pthread_mutex_destroy(&mutex);  // 銷毀互斥鎖

pthread_cancel (id);  // 銷毀執行緒

printf ("%s %d\n", __function__, __line__);

return(0);

}

Linux 基本使用方法

1.圖形使用者介面和命令列介面的切換 圖形介面 命令列介面 可以按ctrl shift alt f2 命令列介面 圖形介面 alt f7,在命令列介面中按 alt f3 是切換另乙個文字介面 如果想開機預設進入命令列介面的話可以修改配置檔案。具體命令如下 在命令介面下,當然,必須要root或者具有r...

LINUX的vim使用方法

linux伺服器用vim來編輯配置檔案和程式設計還是很不錯的,現在已經習慣了這種文字編輯方式.一般拿到新的伺服器都需要自己配置一下vim的環境,要不覺得總是不是很順手.vim初始配置檔案位置 vimrc 一般vim會有乙個預設的配置檔案樣本.我一般會cp到使用者目錄中,然後再修改.cp usr sh...

linux中select使用方法

select系統呼叫是用來讓我們的程式監視多個檔案控制代碼 file descriptor 的狀態變化的。程式會停在select這裡等待,直到被監視的檔案控制代碼有某乙個或多個發生了狀態改變。檔案在控制代碼在linux裡很多,如果你man某個函式,在函式返回值部分說到成功後有乙個檔案控制代碼被建立的...