单片机裸机开发中会经常遇到外设速度过慢,长时间读忙等待,但CPU又不能长时间阻塞的问题。
这种问题可以通过实现一个状态机来异步处理。

异步状态机代码结构示例:

enum
{eIDLE = 0,eSTART,eWAIT,eSUCCESS
};static uint8_t stage = 0;
//启动异步处理
void DoSomethingRequest()
{if(stage != eIDLE){printf("AsyncMachine is busy!!!,return\n");return;}SomethingReq = TRUE;
}
//异步处理任务
void AsyncMachine()
{switch(stage){case eIDLE:if(SomethingReq){stage = eSTART;printf("A task will be start\n");}break;case eSTART: do_something();stage = eWAIT;printf("do something\n");break;case eWAIT: if(something_state() == OK){stage = eSUCCESS;}printf("Wait...\n");break;case eSUCCESS: stage = eIDLE;printf("task exec success\n");break;}
}

通过把阻塞的任务单独分离出来,交给一个状态机子任务来处理。则应用程序只需要调用一个处理请求而无需原地死等,状态机处理完成后,可以异步回调来通知应用程序任务已完成。

下面附上SPI FLASH 同步/异步读写实例。

//SPI状态机状态
typedef enum
{eFLASH_STATE_IDLE = 0,eFLASH_STATE_WRITE = 1, eFLASH_STATE_READ = 2,eFLASH_STATE_BUSY = 3,eFLASH_STATE_ERASE_CHIP = 4,eFLASH_STATE_ERASE = 5,
}FlashState_e;
//SPI设备结构体
typedef struct SpiDevice_s {SPI_TypeDef *spiHandle;//SPI物理属性uint8_t *pTxBuffer;//异步发送缓存uint32_t uTxDstAddr;//异步发送目地地址uint16_t wTxLen;//异步发送长度uint16_t wTxOffset; //异步当前缓存已发送偏移 uint8_t *pRxBuffer;uint32_t uRxSrcAddr;uint16_t wRxLen;uint16_t wRxOffset; void (*pWriteAsyncNotifyCallback)(); //异步写完成回调通知void (*pEraseChipAsyncNotifyCallback)();//异不擦除回调通知struct {FlashState_e eStage;//当前状态机状态//BOOL bTxBusy:1;   //发送忙BOOL bTxReq:1;     //发送请求BOOL bTxCompleted:1;//发送完成//BOOL bRxBusy:1;  //读忙BOOL bRxReq:1;    //读请求BOOL bEraseChipReq:1;//擦整片请求BOOL bEraseSectorReq:1;//擦扇区请求BOOL bEraseSuccess:1; //擦成功}tState;void (*Init)(void);uint8_t (*EraseChip)(void);//同步擦void (*Read)(uint8_t* pBuffer,uint32_t uReadAddr,uint16_t wNumByteToRead);//同步读uint32_t (*WriteByte)(uint8_t Byte, uint32_t uWriteAddr);//同步写字节uint32_t (*Write)(uint8_t* pBuffer,uint32_t uWriteAddr, uint16_t wNumByteToWrite);//同步写BOOL (*WriteAsync)(uint8_t* pBuffer,uint32_t uWriteAddr, uint16_t wNumByteToWrite);//异步写BOOL (*EraseChipAsync)(void);//异步整片擦BOOL (*EraseAsync)(uint32_t uAddr, uint16_t wlen);//奶步擦void (*WriteAsyncNotifyCallbackRegister)(void* pfn);//异步写完成回调注册void (*EraseChipAsyncNotifyCallbackRegister)(void *pfn);//异步擦完成回调注册
}SpiDevice_t;

实例化

SpiDevice_t g_tSpiDevice =
{SPI2,g_aTxBuffer,0,0,0,g_aRxBuffer,0,0,0,0,0,{0,0},Spi_Init,SPI_Flash_Erase_Chip,  //ͬ²½ÕûƬ²ÁSPI_Flash_Read,             //ͬ²½¶ÁSPI_Flash_WriteByte,    //ͬ²½Ð´×Ö½ÚSPI_Flash_Write,            //ͬ²½Ð´SPI_FlashWriteAsync,    //Ò첽дSPI_FlashEraseChipAsync,    //Òì²½ÕûƬ²Á³ýSPI_FlashEraseAsync,SPI_WriteAsyncNotifyCallbackRegister,//д״̬Ò첽֪ͨ»Øµ÷SPI_EraseChipAsyncNotifyCallbackRegister,//²Á³ý״̬Ò첽֪ͨ»Øµ÷
};
//SPI同步操作
/*****************
²Á³ýÒ»¸öÉÈÇø
0~511
******************/
unsigned char SPI_Flash_Erase_Sector(unsigned int Dst_Addr)
{  unsigned char cnt=0; SPI_FLASH_Write_Enable();                  //SET WEL           while((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;}   SPI_CS_LOW();                            SPI_Flash_ReadWrite_Byte(SECTOR_ERASE);      SPI_Flash_ReadWrite_Byte((unsigned char)((Dst_Addr)>>16));   SPI_Flash_ReadWrite_Byte((unsigned char)((Dst_Addr)>>8));  SPI_Flash_ReadWrite_Byte((unsigned char)Dst_Addr); SPI_CS_HIGH();                                         SPI_Flash_Wait_Busy();  return TRUE;
} /*64K Flash¿Õ¼ä²Á³ý*/
unsigned char SPI_Flash_Erase_64k(unsigned int Dst_Addr)
{  unsigned char cnt=0;SPI_FLASH_Write_Enable();                  //SET WEL           while((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;} SPI_CS_LOW();                            SPI_Flash_ReadWrite_Byte(BLOCK_ERASE_64K);      SPI_Flash_ReadWrite_Byte((unsigned char)((Dst_Addr)>>16));   SPI_Flash_ReadWrite_Byte((unsigned char)((Dst_Addr)>>8));  SPI_Flash_ReadWrite_Byte((unsigned char)Dst_Addr); SPI_CS_HIGH();                                         SPI_Flash_Wait_Busy(); return TRUE;
} /*²Á³ýоƬ*/
unsigned char SPI_Flash_Erase_Chip(void)
{   unsigned char cnt=0;     SPI_FLASH_Write_Enable();                  //SET WELwhile((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;}SPI_CS_LOW();                             SPI_Flash_ReadWrite_Byte(CHIP_ERASE);        SPI_CS_HIGH();                                         SPI_Flash_Wait_Busy();  return TRUE;
}  /*Ö¸¶¨µØÖ·¶ÁÈ¡Ö¸¶¨³¤¶ÈÊý¾Ý*/
void SPI_Flash_Read(unsigned char* pBuffer,unsigned int ReadAddr,unsigned short int NumByteToRead)
{unsigned short int index; SPI_CS_LOW();                            SPI_Flash_ReadWrite_Byte(READ_DATA);         /*¸³ÖµµØÖ·*/SPI_Flash_ReadWrite_Byte((unsigned char)((ReadAddr)>>16));   SPI_Flash_ReadWrite_Byte((unsigned char)((ReadAddr)>>8));  SPI_Flash_ReadWrite_Byte((unsigned char)ReadAddr);for(index=0;index<NumByteToRead;index++){pBuffer[index]=SPI_Flash_ReadWrite_Byte(DUMMY); }SPI_CS_HIGH();
} uint32_t SPI_Flash_WriteByte(unsigned char Byte,unsigned int WriteAddr)
{unsigned char cnt=0;SPI_FLASH_Write_Enable();                  //SET WEL           while((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;   /*·µ»Øдʧ°Ü*/} SPI_CS_LOW();                            SPI_Flash_ReadWrite_Byte(PAGE_PRG);      SPI_Flash_ReadWrite_Byte((unsigned char)((WriteAddr)>>16));   SPI_Flash_ReadWrite_Byte((unsigned char)((WriteAddr)>>8));  SPI_Flash_ReadWrite_Byte((unsigned char)WriteAddr);SPI_Flash_ReadWrite_Byte(Byte);SPI_CS_HIGH();                                         SPI_Flash_Wait_Busy();return TRUE;}uint32_t SPI_Flash_Write(unsigned char* pBuffer,unsigned int WriteAddr,unsigned short int NumByteToWrite)
{unsigned short int pageoffset=PAGE_SIZE-(WriteAddr%PAGE_SIZE);  /*¼ÆËã¸ÃÒ³Öл¹ÓжàÉÙÊ£Óà¿Õ¼ä*/unsigned char cnt=0;unsigned short int index;unsigned int pagenum =WriteAddr/PAGE_SIZE;  /*±¾´ÎдÈëµÄÒ³Êý*/unsigned int Addr;if(pageoffset >= NumByteToWrite)  //Ê£Óà¿Õ¼ä´óÓÚҪдµÄÊýÁ¿{SPI_FLASH_Write_Enable();                  //SET WEL           while((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;   /*·µ»Øдʧ°Ü*/} SPI_CS_LOW();                            SPI_Flash_ReadWrite_Byte(PAGE_PRG);      SPI_Flash_ReadWrite_Byte((unsigned char)((WriteAddr)>>16));   SPI_Flash_ReadWrite_Byte((unsigned char)((WriteAddr)>>8));  SPI_Flash_ReadWrite_Byte((unsigned char)WriteAddr); for(index=0; index<NumByteToWrite;index++){SPI_Flash_ReadWrite_Byte(*(pBuffer+index)); }SPI_CS_HIGH();                                         SPI_Flash_Wait_Busy(); return TRUE;}else{/*ÏȽ«¸ÃÒ³ÌîÂú*/SPI_FLASH_Write_Enable();                  //SET WEL           while((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;   /*·µ»Øдʧ°Ü*/} SPI_CS_LOW();                            SPI_Flash_ReadWrite_Byte(PAGE_PRG);      SPI_Flash_ReadWrite_Byte((unsigned char)((WriteAddr)>>16));   SPI_Flash_ReadWrite_Byte((unsigned char)((WriteAddr)>>8));  SPI_Flash_ReadWrite_Byte((unsigned char)WriteAddr); for(index=0; index<pageoffset;index++){SPI_Flash_ReadWrite_Byte(*(pBuffer+index)); }SPI_CS_HIGH();                                         SPI_Flash_Wait_Busy(); NumByteToWrite -=pageoffset;  /*³¤¶È¼õȥдÈëÊý¾Ý*/pagenum++;Addr = pagenum*PAGE_SIZE;  //»ñÈ¡ÏÂÒ»Ò³µÄÆðʼµØÖ·while(NumByteToWrite >0){if(NumByteToWrite > PAGE_SIZE)  //ÈÔÈ»´óÓÚÒ»Ò³{SPI_FLASH_Write_Enable();                  //SET WEL           while((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;   /*·µ»Øдʧ°Ü*/} SPI_CS_LOW();                            SPI_Flash_ReadWrite_Byte(PAGE_PRG);      SPI_Flash_ReadWrite_Byte((unsigned char)((Addr)>>16));   SPI_Flash_ReadWrite_Byte((unsigned char)((Addr)>>8));  SPI_Flash_ReadWrite_Byte((unsigned char)Addr); for(index=0; index<PAGE_SIZE;index++){SPI_Flash_ReadWrite_Byte(*(pBuffer+index+pageoffset)); }SPI_CS_HIGH();                                         SPI_Flash_Wait_Busy();NumByteToWrite -=PAGE_SIZE;pageoffset +=PAGE_SIZE;pagenum++;Addr = pagenum*PAGE_SIZE;  //»ñÈ¡ÏÂÒ»Ò³µÄÆðʼµØÖ·}else{SPI_FLASH_Write_Enable();                  //SET WEL           while((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;   /*·µ»Øдʧ°Ü*/} SPI_CS_LOW();                            SPI_Flash_ReadWrite_Byte(PAGE_PRG);      SPI_Flash_ReadWrite_Byte((unsigned char)((Addr)>>16));   SPI_Flash_ReadWrite_Byte((unsigned char)((Addr)>>8));  SPI_Flash_ReadWrite_Byte((unsigned char)Addr); for(index=0; index<NumByteToWrite;index++){SPI_Flash_ReadWrite_Byte(*(pBuffer+index+pageoffset)); }SPI_CS_HIGH();                                         SPI_Flash_Wait_Busy();NumByteToWrite =0;}}return TRUE;}
}
/************************************************************************************************SPI异步操作*************************************************************************************************//*****************************************************************************************
º¯ÊýÃû³Æ:SPI_FlashWriteAsync异步写请求
º¯ÊýÃèÊö:Ò첽д
ÊäÈë²ÎÊý:
Êä³ö²ÎÊý:
º¯Êý·µ»Ø:
******************************************************************************************/
BOOL SPI_FlashWriteAsync(uint8_t* pBuffer,uint32_t uWriteAddr, uint16_t wNumByteToWrite)
{if(wNumByteToWrite > FLASH_TX_BUFFER_SIZE){return FALSE;}if(g_tSpiDevice.tState.eStage != eFLASH_STATE_IDLE){Debug(eDBUG_LEVEL_ERROR,"[%d]Flash_Write:busy,return\r\n", GetTicks());return FALSE;}memcpy(g_tSpiDevice.pTxBuffer, pBuffer, wNumByteToWrite);g_tSpiDevice.wTxLen = wNumByteToWrite;g_tSpiDevice.uTxDstAddr = uWriteAddr;g_tSpiDevice.wTxOffset = 0;g_tSpiDevice.tState.bTxReq = TRUE; //请求标志g_tSpiDevice.tState.bTxCompleted = FALSE;//g_tSpiDevice.tState.bTxBusy = TRUE;return TRUE;
}
/*****************************************************************************************
º¯ÊýÃû³Æ:SPI_FlashWriteAsync
º¯ÊýÃèÊö:Òì²½²ÁÕûƬ
ÊäÈë²ÎÊý:
Êä³ö²ÎÊý:
º¯Êý·µ»Ø:
******************************************************************************************/
BOOL SPI_FlashEraseChipAsync(void)
{//unsigned char cnt=0;     if(g_tSpiDevice.tState.eStage != eFLASH_STATE_IDLE){Debug(eDBUG_LEVEL_ERROR,"[%d]Flash_earse:busy,return\r\n", GetTicks());return FALSE;}g_tSpiDevice.tState.bEraseChipReq = TRUE;return TRUE;
}
/*****************************************************************************************
º¯ÊýÃû³Æ:异步擦除
º¯ÊýÃèÊö:Òì²½²ÁÖ¸¶¨µØÖ·
ÊäÈë²ÎÊý:
Êä³ö²ÎÊý:
º¯Êý·µ»Ø:
******************************************************************************************/
BOOL SPI_FlashEraseAsync(uint32_t uAddr, uint16_t wlen)
{//unsigned char cnt=0;     if(g_tSpiDevice.tState.eStage != eFLASH_STATE_IDLE){Debug(eDBUG_LEVEL_ERROR,"[%d]Flash_earse:busy,return\r\n", GetTicks());return FALSE;}g_tSpiDevice.wTxLen = wlen;g_tSpiDevice.uTxDstAddr = uAddr;g_tSpiDevice.wTxOffset = 0;g_tSpiDevice.tState.bEraseSectorReq = TRUE;return TRUE;
}
//注册完成通知
void SPI_WriteAsyncNotifyCallbackRegister(void *pfn)
{g_tSpiDevice.pWriteAsyncNotifyCallback = (void (*)())pfn;
}
void SPI_EraseChipAsyncNotifyCallbackRegister(void *pfn)
{g_tSpiDevice.pEraseChipAsyncNotifyCallback = (void (*)())pfn;
}//ÅжÏSPI FLASH æ
static BOOL SPI_FlashBusyCheck(void)
{if((SPI_Flash_Read_SR()&0x01)==0x01){return TRUE;} else {return FALSE;}
}
//дһҳ
static BOOL __SPI_FlashWritePage(uint32_t uWriteAddr, uint8_t *pData, uint16_t wWriteLen)
{uint8_t  cnt;uint16_t index;SPI_FLASH_Write_Enable();                  //SET WEL           while((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;   /*·µ»Øдʧ°Ü*/} SPI_CS_LOW();                            SPI_Flash_ReadWrite_Byte(PAGE_PRG);      SPI_Flash_ReadWrite_Byte((unsigned char)((uWriteAddr)>>16));   SPI_Flash_ReadWrite_Byte((unsigned char)((uWriteAddr)>>8));  SPI_Flash_ReadWrite_Byte((unsigned char)uWriteAddr); for(index=0; index < wWriteLen; index++){SPI_Flash_ReadWrite_Byte(*(pData+index)); }SPI_CS_HIGH();return TRUE;
}
//Ò첽д´¦Àí×ÓÈÎÎñ
static int32_t __SPI_FlashWrite(void)
{uint16_t wWriteRemainNum = g_tSpiDevice.wTxLen - g_tSpiDevice.wTxOffset;uint8_t *pData = g_tSpiDevice.pTxBuffer + g_tSpiDevice.wTxOffset;uint32_t uWriteAddr = g_tSpiDevice.uTxDstAddr + g_tSpiDevice.wTxOffset;uint16_t wPageRemain = PAGE_SIZE - (uWriteAddr % PAGE_SIZE);//ÅжÏдÍê³Éif(wWriteRemainNum == 0){//дÍê³Ég_tSpiDevice.tState.bTxCompleted = TRUE;//g_tSpiDevice.tState.bRxBusy = FALSE;g_tSpiDevice.tState.bTxReq = FALSE;g_tSpiDevice.tState.eStage = eFLASH_STATE_IDLE; //дÍê³É ת¿ÕÏÐif(g_tSpiDevice.pWriteAsyncNotifyCallback){//TODO Ò첽֪ͨ»Øµ÷ ¹©µ÷ÓÃÕßʵÏÖg_tSpiDevice.pWriteAsyncNotifyCallback();}return eSUCCESS;}        //СÓÚһҳʣÓà¿Éд×Ö½Úif(wWriteRemainNum <= wPageRemain){__SPI_FlashWritePage(uWriteAddr, pData, wWriteRemainNum);g_tSpiDevice.wTxOffset += wWriteRemainNum;//дÍêÊ£Óà}else {__SPI_FlashWritePage(uWriteAddr, pData, wPageRemain);g_tSpiDevice.wTxOffset += wPageRemain;//дһÕûÒ³£¬}//Òì²½¶Áæg_tSpiDevice.tState.eStage = eFLASH_STATE_BUSY;return eSUCCESS;
}
//Òì²½¶Áæ×ÓÈÎÎñ
static void __SPI_FlashBusy(void)
{//¶Áæ ·Ç×èÈûif(SPI_FlashBusyCheck()){return ;}//SPIÉϴβÙ×÷ÒÑÍê³É//TX processif(g_tSpiDevice.tState.bTxReq == TRUE){g_tSpiDevice.tState.eStage = eFLASH_STATE_WRITE;}//RX process// TODO ²Á³ýÒÑÍê³Éif(g_tSpiDevice.tState.bEraseChipReq == TRUE){g_tSpiDevice.tState.eStage = eFLASH_STATE_ERASE_CHIP;}if(g_tSpiDevice.tState.bEraseSectorReq == TRUE){g_tSpiDevice.tState.eStage = eFLASH_STATE_ERASE;}
}
//Òì²½²Á³ý×ÓÈÎÎñ ÕûƬ
static int32_t __SPI_FlashEraseChip(void)
{uint8_t cnt = 0;SPI_FLASH_Write_Enable();                  //SET WELif(g_tSpiDevice.tState.bEraseSuccess == TRUE){g_tSpiDevice.tState.bEraseSuccess = FALSE;g_tSpiDevice.tState.bEraseChipReq = FALSE;g_tSpiDevice.tState.eStage = eFLASH_STATE_IDLE;//дÍê³É ת¿ÕÏÐif(g_tSpiDevice.pEraseChipAsyncNotifyCallback){TODO Ò첽֪ͨ»Øµ÷ ¹©µ÷ÓÃÕßʵÏÖg_tSpiDevice.pEraseChipAsyncNotifyCallback();}return TRUE;}while((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;}SPI_CS_LOW();                             SPI_Flash_ReadWrite_Byte(CHIP_ERASE);        SPI_CS_HIGH();                                         //SPI_Flash_Wait_Busy(); g_tSpiDevice.tState.eStage = eFLASH_STATE_BUSY;//Òì²½¶Áæreturn TRUE;
}
//Òì²½²Á³ý×ÓÈÎÎñ
static int32_t __SPI_FlashErase(void)
{uint8_t cnt = 0;  //uint32_t uSectorIdxFirst = g_tSpiDevice.uTxDstAddr/SECTOR_SIZE;uint32_t uSectorIdxTail = (g_tSpiDevice.uTxDstAddr+g_tSpiDevice.wTxLen)/SECTOR_SIZE;uint32_t uCurrentSectorIdx = (g_tSpiDevice.uTxDstAddr + g_tSpiDevice.wTxOffset)/SECTOR_SIZE;if(uCurrentSectorIdx > uSectorIdxTail){g_tSpiDevice.tState.bEraseSectorReq = FALSE;g_tSpiDevice.tState.bEraseSuccess = TRUE;g_tSpiDevice.tState.eStage = eFLASH_STATE_IDLE;//дÍê³É ת¿ÕÏÐif(g_tSpiDevice.pEraseChipAsyncNotifyCallback){TODO Ò첽֪ͨ»Øµ÷ ¹©µ÷ÓÃÕßʵÏÖg_tSpiDevice.pEraseChipAsyncNotifyCallback();}return TRUE;}SPI_FLASH_Write_Enable();                  //SET WELwhile((SPI_Flash_Read_SR()&0x2)!=0x2) {cnt ++;if(cnt >200)return FALSE;}SPI_CS_LOW();                            SPI_Flash_ReadWrite_Byte(SECTOR_ERASE);      SPI_Flash_ReadWrite_Byte((unsigned char)((uCurrentSectorIdx*SECTOR_SIZE)>>16));   SPI_Flash_ReadWrite_Byte((unsigned char)((uCurrentSectorIdx*SECTOR_SIZE)>>8));  SPI_Flash_ReadWrite_Byte((unsigned char)(uCurrentSectorIdx*SECTOR_SIZE)); SPI_CS_HIGH(); g_tSpiDevice.wTxOffset += SECTOR_SIZE;//SPI_Flash_Wait_Busy(); g_tSpiDevice.tState.eStage = eFLASH_STATE_BUSY;//Òì²½¶Áæreturn TRUE;
}
//¿ÕÏд¦Àí×ÓÈÎÎñ
static void __SPI_FlashIdle(void)
{//Æô¶¯¸÷ÏîÈÎÎñif(g_tSpiDevice.tState.bTxReq == TRUE){g_tSpiDevice.tState.eStage = eFLASH_STATE_WRITE;} else if(g_tSpiDevice.tState.bRxReq == TRUE){g_tSpiDevice.tState.eStage = eFLASH_STATE_READ;} else if(g_tSpiDevice.tState.bEraseChipReq == TRUE){g_tSpiDevice.tState.eStage = eFLASH_STATE_ERASE_CHIP;}else if(g_tSpiDevice.tState.bEraseSectorReq == TRUE){g_tSpiDevice.tState.eStage = eFLASH_STATE_ERASE;}
}
//SPIÒì²½²Ù×÷´¦Àí×ÜÈÎÎñ
void SPI_FlashAsyncProcTask(void)
{switch(g_tSpiDevice.tState.eStage){case eFLASH_STATE_IDLE:__SPI_FlashIdle();break;case eFLASH_STATE_WRITE:__SPI_FlashWrite();break;case eFLASH_STATE_READ://TODObreak;case eFLASH_STATE_BUSY:__SPI_FlashBusy();break;case eFLASH_STATE_ERASE_CHIP:__SPI_FlashEraseChip();break;case eFLASH_STATE_ERASE:__SPI_FlashErase();break;default:break;}}







												

SpiFlash同步/异步读写单片机裸机实例相关推荐

  1. linux下aio异步读写详解与实例

    1.为什么会有异步I/O aio异步读写是在linux内核2.6之后才正式纳入其标准.之所以会增加此模块,是因为众所周知我们计算机CPU的执行速度远大于I/O读写的执行速度,如果我们用传统的阻塞式或非 ...

  2. PIC单片机入门_同步/异步通信技术基础

    1.前言 通用同步 / 异步收发器 (Universal Synchronous/Asynchronous Receiver/Transmitter, USART) 模块是两个串行 I/O 模块之一 ...

  3. NIO详解(二): BIO 浅谈 同步 异步与阻塞 非阻塞

    在我们了解Java NIO/BIO的网络通信之前,我们先了解一下常用的阻塞/非阻塞模型以及同步/异步的概念 一.阻塞和非阻塞 从简单的开始,我们以经典的读取文件的模型举例.(对操作系统而言,所有的输入 ...

  4. 面试必会系列 - 5.1 网络BIO、NIO、epoll,同步/异步模型、阻塞/非阻塞模型,你能分清吗?

    本文已收录至 Github(MD-Notes),若博客中图片模糊或打不开,可以来我的 Github 仓库,包含了完整图文:https://github.com/HanquanHq/MD-Notes,涵 ...

  5. 确定不来了解一下什么是 BIO NIO AIO 阻塞 非阻塞 同步 异步?

    本文内容涉及同步与异步, 阻塞与非阻塞, BIO.NIO.AIO等概念, 这块内容本身比较复杂, 很难用三言两语说明白. 而书上的定义更不容易理解是什么意思. 下面跟着我一起解开它们神秘的面纱. BI ...

  6. C#.net同步异步SOCKET通讯和多线程总结(转)

    C#.net同步异步SOCKET通讯和多线程总结 来源:http://www.cnblogs.com/Silverlight_Team/archive/2009/03/13/1411136.html ...

  7. 彻底理解同步异步阻塞与非阻塞

    彻底理解同步异步阻塞与非阻塞 前言 用户空间 内核空间 系统调用 用户态 内核态 系统IO 阻塞非阻塞 同步异步 前言 最近有同事问我同步异步与阻塞非阻塞有什么区别,后来发现很多同事不能区分这些概念. ...

  8. 【FPGA】双端口RAM的设计(异步读写)

    上篇写了双端口RAM设计(同步读写):https://blog.csdn.net/Reborn_Lee/article/details/90647784 关于异步读写和同步读写,在单端口RAM设计中也 ...

  9. 迄今为止把同步/异步/阻塞/非阻塞/BIO/NIO/AIO讲的这么清楚的好文章(快快珍藏)...

    常规的误区 假设有一个展示用户详情的需求,分两步,先调用一个HTTP接口拿到详情数据,然后使用适合的视图展示详情数据. 如果网速很慢,代码发起一个HTTP请求后,就卡住不动了,直到十几秒后才拿到HTT ...

最新文章

  1. Microsoft Build 2021大会开始后,Develop Blog一系列更新
  2. sql 返回日期的年月部分_公示|2020年11月部分志愿活动名单公示
  3. matlab 画三维花瓶,精美花瓶建模教程
  4. 详细讲述CV的创作与包装
  5. 企业微信3.0版本发布:客户朋友圈功能正式上线
  6. win10计算机错误代码,Win10错误代码:0xc00000f 解决方案
  7. 2021年中国充油散热器市场趋势报告、技术动态创新及2027年市场预测
  8. 「倾心整理~」数据库系统概论—第5章(数据库完整性)
  9. FIT 2019 | 安全人员面临的机遇与挑战
  10. Myeclipse如何使用自带git工具向远程仓库提交代码(转)
  11. 安恒赛php_安恒四月赛部分Writeup
  12. Cost Function of Support Vector Machine
  13. Halcon 3D 计算3D模型的3D表面法线
  14. OBS-RTMP推流
  15. js上传插件uploadify自动检测不到flash控件的问题
  16. Ubuntu16.04使用语义分割标注工具Semantic-Segmentation-Editor
  17. TOMCAT的AppBase和DocBase研究
  18. 电子科技大学计算机科学与技术考研复试,电子科技大学计算机科学与工程学院2021考研招生复试工作安排...
  19. dbeave连接达梦数据库简单操作使用
  20. Haproxy(一)基础介绍

热门文章

  1. matlab绘制脑电地形图,脑电地形图的原理及其结果
  2. 哈工大刘宏伟《计算机组成原理》课程框架总结
  3. C语言之复数的加减乘除
  4. 先电云计算大赛大数据平台搭建
  5. Final Cut Pro X 教程
  6. FCPX插件 图标和徽标动画 CineFlare KineticBadges v1.0.3破解版
  7. 模型训练前后显卡占用对比、多卡训练GPU占用分析【一文读懂】
  8. 【Bug解决记录】类文件具有错误的版本 61.0, 应为 52.0
  9. 计算机windows7显卡怎么检测,windows系统怎么查看自己电脑的显卡?
  10. (多线程同步练习)桌子上有一只盘子,每次只能放一只水果,爸爸专向盘子中放苹果,妈妈专向盘子中放橘子,一个儿子专等吃盘子里的橘子,一个女儿专等吃盘子里的苹果。写出能使爸爸、妈妈、儿子、女儿正确同步工作的