Linux C notes (BOOK UNIX)
Chapter 1: Thread
¢Ù thread functions
1. pthread_self();
2. thread existing
you can get the value of rval_ptr just by pthread_join(pthread_t tht, void ** rval_ptr)
cancel a thread as the thread exits with PTHREAD_CANCELED in pthread_exit, this function only send a signal but not wait until the thread really exits
We can give a function to a thread with which the thread can invoke it when it exits. This
pthread_clean_push
These two functions must be in pairs in your function routines but not in the main function. And one thing should be mentioned as : the routine should not be returned but
pthread_detach(pthread_t tid)
4. Thread synchronization of thread
¢Ú thread. synchronics
pthread_mutex_t variable
pthread_mutex_destroy()
ii. Lock
pthread_mutex_trylock() return instantly
pthread_unlock()
pthread_rwlook_t
pthread_rwlock_init
pthread_rwlock_destroy
ii. Lock
pthread_rwlock_wrlook
pthread_rwlock_unlock
pthread_rwlock_tryrdlock
pthread_rwlock_trywrlock
3. Cond
i. initiation
pthread_cond_init(&pcndt, attr);
Ïà¹ØÎĵµ£º
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
1. Òý×Ó
int a;
int size = 8;
Èç¹ûÈÃaΪ(size =8)µÄÕûÊý±¶±íʾ³É¶þ½øÖÆÓ¦ÊÇʲôÑù×ÓÄØ£¿ÄǾÍÊÇÈÃÕâ¸öÊý±íʾ³É¶þ½øÖÆʱµÄ×îºóÈýλΪ0.
¶øÒª´ïµ½ÕâһĿ±ê£¬Ö»ÒªÏÂÃæÕâ¸öÊýÓëËü½øÐÐÓëÔËËã¾Í¿ÉÒÔÁË:
11111111 11111111 11111111 11111000
¶øÉÏÃæÕâ¸öÊýʵ¼ÊϾÍÊ ......
Á´±íÖÐÓÐÁ½¸ö¹Ø¼üµÄ²Ù×÷£º´´½¨ºÍɾ³ý¡£½ñÌìÎҾͶÔÕâÁ½¸ö²Ù×÷½øÐнéÉÜ£¬
´ÓÕâÁ½¸ö²Ù×÷ÖÐѧϰµ½Á´±íµÄ»ù±¾Ó÷¨¡£
1. Create
Create() ÊÇÒ»¸öÁ´±í»ù´¡£¬Ö»Óн¨Á¢ºÃÁ´±í²ÅÄܶÔËü½øÐÐÏàÓ¦µÄ²éÕÒ£¬É¾³ý µÈ¡£
»ù±¾Ëã·¨£º
1.³õʼ»¯
head=NULL;
......
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <windows.h>
#include <iostream>
using namespace std;
class student{
private:
char name[20],addr[40];
char id_number[40],phone[20];
public:
void searchstud_info();
void ......
1.¸ÅÂÛ
¡¡ÔËÐÐʱ¿âÊdzÌÐòÔÚÔËÐÐʱËùÐèÒªµÄ¿âÎļþ£¬Í¨³£ÔËÐÐʱ¿âÊÇÒÔLIB»òDLLÐÎʽÌṩµÄ¡£CÔËÐÐʱ¿âµ®ÉúÓÚ20ÊÀ¼Í70Äê´ú£¬µ±Ê±µÄ³ÌÐòÊÀ½ç»¹ºÜµ¥´¿£¬Ó¦ÓóÌÐò¶¼Êǵ¥Ï̵߳ģ¬¶àÈÎÎñ»ò¶àÏ̻߳úÖÆÔÚ´Ëʱ»¹ÊôÓÚйÛÄî¡£ËùÒÔÕâ¸öʱÆÚµÄCÔËÐÐʱ¿â¶¼Êǵ¥Ï̵߳ġ£
Ëæ×ŲÙ×÷ϵͳ¶àÏ̼߳¼ÊõµÄ·¢Õ¹£¬×î³õµÄCÔËÐÐʱ¿âÎÞ·¨Âú×ã³ÌÐòµÄÐèÇó£ ......