Книга: Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

Synchronous Access

Synchronous Access

Synchronous memory access is synonymous with non-concurrent buffer access. The caller's thread waits until the function call returns, such as DeviceIoControl, and there are no other threads in the caller process that access the buffer while the driver performs its processing tasks. In this scenario, the device driver can use parameter pointers and embedded pointers (after a call to CeOpenCallerBuffer) without additional precautions.

The following is an example of accessing a buffer from an application synchronously. This sample source code is an excerpt from an XXX_IOControl function of a stream driver:

BOOL SMP_IOControl(DWORD hOpenContext, DWORD dwCode,
 PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut,
 PDWORD pdwActualOut) {
 BYTE *lpBuff = NULL;
 ...
 if (dwCode == IOCTL_A_WRITE_FUNCTION) {
  // Check parameters
  if ( pBufIn == NULL || dwLenIn != sizeof(AN_INPUT_STRUCTURE)) {
   DEBUGMSG(ZONE_IOCTL, (TEXT("Bad parametersrn")));
   return FALSE;
  }
  // Access input buffer
  hrMemAccessVal = CeOpenCallerBuffer((PVOID) &lpBuff,
   (PVOID) pBufIn, dwLenIn, ARG_I_PTR, FALSE);
  // Check hrMemAccessVal value
  // Access the pBufIn through lpBuff
  ...
  // Close the buffer when it is no longer needed
  CeCloseCallerBuffer((PVOID)lpBuff, (PVOID)pBufOut,
   dwLenOut, ARG_I_PTR);
 }
 ...
}

Оглавление книги

Оглавление статьи/книги

Генерация: 1.167. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз