Éú²úÕß Ïû·ÑÕßÎÊÌâʵÏÖ (linuxÏÂCÓïÑÔ)
²Ù×÷ϵͳµÄÒ»¸ö¾µäÎÊÌâÊÇ"Éú²úÕß-Ïû·ÑÕß"ÎÊÌâ, ÕâÉ漰ͬ²½ÐźÅÁ¿ºÍ»¥³âÐźÅÁ¿µÄÓ¦ÓÃ, ÔÚÕâÀï,ÎÒÓÃÏ̵߳Äͬ²½ºÍ»¥³âÀ´ÊµÏÖ.
/*
* author ÕÅÎÄ
* 2008/06/20
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
#define N 2 // Ïû·ÑÕß»òÕßÉú²úÕßµÄÊýÄ¿
#define M 10 // »º³åÊýÄ¿
int in = 0; // Éú²úÕß·ÅÖòúÆ·µÄλÖÃ
int out = 0; // Ïû·ÑÕßÈ¡²úÆ·µÄλÖÃ
int buff[M] = {0}; // »º³å³õʼ»¯Îª0£¬ ¿ªÊ¼Ê±Ã»ÓвúÆ·
sem_t empty_sem; // ͬ²½ÐźÅÁ¿£¬ µ±ÂúÁËʱ×èÖ¹Éú²úÕ߷ŲúÆ·
sem_t full_sem; // ͬ²½ÐźÅÁ¿£¬ µ±Ã»²úƷʱ×èÖ¹Ïû·ÑÕßÏû·Ñ
pthread_mutex_t mutex; // »¥³âÐźÅÁ¿£¬ Ò»´ÎÖ»ÓÐÒ»¸öÏ̷߳ÃÎÊ»º³å
int product_id = 0; //Éú²úÕßid
int prochase_id = 0; //Ïû·ÑÕßid
/* ´òÓ¡»º³åÇé¿ö */
void print()
{
int i;
for(i = 0; i < M; i++)
printf("%d ", buff[i]);
printf("\n");
}
/* Éú²úÕß·½·¨ */
void *product()
{
int id = ++product_id;
while(1)
{
// ÓÃsleepµÄÊýÁ¿¿ÉÒÔµ÷½ÚÉú²úºÍÏû·ÑµÄËٶȣ¬±ãÓÚ¹Û²ì
sleep(1);
//sleep(1);
sem_wait(&empty_sem);
pthread_mutex_lock(&mutex);
in = in % M;
printf("product%d in %d. like: \t", id, in);
buff[in] = 1;
print();
++in;
pthread_mutex_unlock(&mutex);
sem_post(&full_sem);
}
}
/* Ïû·ÑÕß·½·¨ */
void *prochase()
{
int id = ++prochase_id;
while(1)
{
// ÓÃsleepµÄÊýÁ¿¿ÉÒÔµ÷½ÚÉú²úºÍÏû·ÑµÄËٶȣ¬±ãÓÚ¹Û²ì
sleep(1);
//sleep(1);
sem_wait(&full_sem);
pthread_mutex_lock(&mutex);
out = out % M;
printf("prochase%d in %d. like: \t", id, out);
&nb
Ïà¹ØÎĵµ£º
1. HCI²ãÐÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI) ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈÐÒé ......
£¨L2CAPÐÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPÐÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼Á¬½Ó¿ØÖƺÍÊÊÅäÐÒé (L2CAP) ΪÉϲãÐÒéÌṩÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àÐÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãÐÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......
LinuxÖеȴý¶ÓÁлúÖÆ·ÖÎö
ʲôÊǵȴý¶ÓÁУ¿
ÔÚÈí¼þ¿ª·¢ÖÐÈÎÎñ¾³£ÓÉÓÚijÖÖÌõ¼þûÓеõ½Âú×ã¶ø²»µÃ²»½øÈë˯Ãß״̬£¬È»ºóµÈ´ýÌõ¼þµÃµ½Âú×ãµÄʱºòÔÙ¼ÌÐøÔËÐУ¬½øÈëÔËÐÐ״̬¡£ÕâÖÖÐèÇóÐèÒªµÈ´ý¶ÓÁлúÖƵÄÖ§³Ö¡£LinuxÖÐÌṩÁ˵ȴý¶ÓÁеĻúÖÆ£¬¸Ã»úÖÆÔÚÄÚºËÖÐÓ¦Óúܹ㷺¡£
......
CÊÇÃæÏò¹ý³ÌµÄ³ÌÐòÉè¼Æ£¬³ÌÐò=Êý¾Ý½á¹¹+Ëã·¨ [×îÔʼ£¬µ«±à¸ö³Ìȷʵ²»Ò×]
C++ÊÇÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼Æ£¬³ÌÐò=¶à¸öÀà+ÏûÏ¢(Àà=Êý¾Ý½á+Ëã·¨)[±È½ÏÈÝÒ×ÉÏÊÖ]
C# ÊÇ´¿ÃæÏò¶ÔÏóµÄÓïÑÔ[¸ü¼Ó±È½ÏÈÝÒ×ÉÏÊÖ]
VC/VC++/VC# Ö»ÊÇÓÃÀ´¿ª·¢C/C++/C#Ó¦ÓóÌÐòµÄÈí¼þÖеÄÒ»ÖÖ¡£
......
¹À¼ÆÊDZ»¹¥»÷ÁË£¬¹ý¸ö¼ÙÆÚssh¾ÍÁ¬½Ó²»ÉÏÁË£¬Ô¶³ÌÁ¬½ÓÌáʾ network refused¡£Ö»ÄÜÅܵ½»ú·¿¿´¸ö¾¿¾¹£¬Ê×ÏÈÓôó¼ÒµÄÐ޸ķ½Ê½£º
LinuxÏÂSSHĬÈÏ22¶Ë¿ÚµÄÐ޸ķ½·¨ÈçÏÂ:
NO 1£º
01¼ÙÈçÒª¸ÄSSHµÄĬÈ϶˿ڣ¨22£©£¬ÄÇôÄãÖ»ÒªÐ޸ģº/etc/ssh/sshd_configÖÐPort 22£¬ÕâÀï°Ñ22¸Ä³É×Ô¼ºÒªÉèµÄ¶Ë¿Ú¾ÍÐÐÁË£¬²»¹ýǧÍò±ðÉèºÍÏÖÒÑÓеĶ ......