主题中讨论的其他器件:SysConfig
我有一个多客户端服务器、其中每个工作线程处理客户端、就像在 tcpecho 中一样。 我正在尝试使用 CryptoCC32XX。 问题是、我 每个线程应该使用一个 CryptoCC32XX_Handle、还是所有线程都使用一个全局 CryptoCC32XX_Handle? 缓冲区大小和密钥对于所有线程都相同。
在 CryptoCC32XX.h 文件参考(TI.com)的文档中 "该驱动程序中的 API 用作一个典型 TI-RTOS 应用程序的接口。 特定外设的实现负责创建所有 OSAL 特定基元、从而实现线程安全操作。" 什么是 OSAL?
g_aCryptoH[CLIMX]={0}; // iclient for use by thread int get_buffer_id() { if (g_Crypt_Init=0) CryptoCC32XX_init(); int iret = -1; for (int i = 0; i < CLIMX; i++) { if (aibuffer_id[i] == 0) { aibuffer_id[i] = 1; iret = i; // do I get a thread crypto here? or is it not threadsafe and since // all keys are the same for all clients, one CryptoCC32XX_Handle and block until // done with buffer on thread and release? // g_aCryptoH[i] = CryptoCC32XX_open( i,CryptoCC32XX_AES_CBC); break; } } return iret; } void unget_buffer_id(int id) { id = id % CLIMX; msgini(id, MSGS); // zeros memory and sets all buffers available aibuffer_id[id] = 0; CryptoCC32XX_close(g_aCryptoH[id]; g_aCryptoH[id] = 0; }