Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Éú²úÕß Ïû·ÑÕßÎÊÌâʵÏÖ (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


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì£¨Èý£© HCI²ã±à³Ì

1. HCI²ãЭÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI)  ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈЭÒé ......

ʵսLinux Bluetooth±à³Ì£¨ËÄ£© L2CAP²ã±à³Ì

£¨L2CAPЭÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPЭÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼­Á¬½Ó¿ØÖƺÍÊÊÅäЭÒé (L2CAP) ΪÉϲãЭÒéÌṩÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àЭÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãЭÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......

LinuxÖеȴý¶ÓÁлúÖÆ·ÖÎö

 LinuxÖеȴý¶ÓÁлúÖÆ·ÖÎö
 
ʲôÊǵȴý¶ÓÁУ¿
       ÔÚÈí¼þ¿ª·¢ÖÐÈÎÎñ¾­³£ÓÉÓÚijÖÖÌõ¼þûÓеõ½Âú×ã¶ø²»µÃ²»½øÈë˯Ãß״̬£¬È»ºóµÈ´ýÌõ¼þµÃµ½Âú×ãµÄʱºòÔÙ¼ÌÐøÔËÐУ¬½øÈëÔËÐÐ״̬¡£ÕâÖÖÐèÇóÐèÒªµÈ´ý¶ÓÁлúÖƵÄÖ§³Ö¡£LinuxÖÐÌṩÁ˵ȴý¶ÓÁеĻúÖÆ£¬¸Ã»úÖÆÔÚÄÚºËÖÐÓ¦Óúܹ㷺¡£ ......

C¡¢C++ºÍC#µÄ²»Í¬Ö®´¦

CÊÇÃæÏò¹ý³ÌµÄ³ÌÐòÉè¼Æ£¬³ÌÐò=Êý¾Ý½á¹¹+Ëã·¨ [×îԭʼ£¬µ«±à¸ö³Ìȷʵ²»Ò×]
C++ÊÇÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼Æ£¬³ÌÐò=¶à¸öÀà+ÏûÏ¢(Àà=Êý¾Ý½á+Ëã·¨)[±È½ÏÈÝÒ×ÉÏÊÖ]
C# ÊÇ´¿ÃæÏò¶ÔÏóµÄÓïÑÔ[¸ü¼Ó±È½ÏÈÝÒ×ÉÏÊÖ]
VC/VC++/VC# Ö»ÊÇÓÃÀ´¿ª·¢C/C++/C#Ó¦ÓóÌÐòµÄÈí¼þÖеÄÒ»ÖÖ¡£
......

linuxµÄsshdÆô¶¯Ê§°Ü


¹À¼ÆÊDZ»¹¥»÷ÁË£¬¹ý¸ö¼ÙÆÚssh¾ÍÁ¬½Ó²»ÉÏÁË£¬Ô¶³ÌÁ¬½ÓÌáʾ network refused¡£Ö»ÄÜÅܵ½»ú·¿¿´¸ö¾¿¾¹£¬Ê×ÏÈÓôó¼ÒµÄÐ޸ķ½Ê½£º
LinuxÏÂSSHĬÈÏ22¶Ë¿ÚµÄÐ޸ķ½·¨ÈçÏÂ:
NO 1£º
01¼ÙÈçÒª¸ÄSSHµÄĬÈ϶˿ڣ¨22£©£¬ÄÇôÄãÖ»ÒªÐ޸ģº/etc/ssh/sshd_configÖÐPort 22£¬ÕâÀï°Ñ22¸Ä³É×Ô¼ºÒªÉèµÄ¶Ë¿Ú¾ÍÐÐÁË£¬²»¹ýǧÍò±ðÉèºÍÏÖÒÑÓеĶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ