.


:




:

































 

 

 

 





. , , - , . , , .

:

#include <sys/shm.h>

int shmget(key_t key, size_t size, int flag);

 

:

key . ;

tsize , ;

flag , .

, -1. , , key.

shmat():

#include <sys/shm.h>

void *shmat(int shmid, const void *addr, int flag);

, , , . . , , , . shmdt() .

shmctl(). , , /. Unix-; Linux Solaris.

, . exit() exec() , . shmctl() IPC_RMID. , , , .

 

Windows

 

Windows .

 

Linux, Windows . , , , , . Windows : . , - , , . , .

Windows Linux. . :

 

BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize);

, :

hReadPipe ;

hWritePipe ;

lpPipeAttributes ;

nSize , .

 

:

 

HANDLE CreateNamedPipe(LPCTSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes);

 

:

lpName . , : \\ \pipe\ . \\.\pipe\ ;

dwOpenMode ;

nMaxInstances ;

nOutBufferSize ;

nInBufferSize ;

nDefaultTimeOut , ;

lpSecurityAttributes .

 

: ConnectNamedPipe() ( ), CreateFile(), ReadFile(), WriteFile(). .

 

, . , (File Mapping), , .

. , .

. :

HANDLE WINAPI CreateFileMapping(HANDLE hFile, LPSECURITY_ATTRIBUTES lpAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCTSTR lpName);

 

:

hFile , . , , INVALID_HANDLE_VALUE. . dwMaximumSizeHigh dwMaximumSizeLow;

lpAttributes ;

flProtect ;

dwMaximumSizeHigh , ;

dwMaximumSizeLow , ;

lpName .

, . :

LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap);

 

:

hFileMappingObject , ;

dwDesiredAccess ;

dwFileOffsetHigh , ;

dwFileOffsetLow ;

dwNumberOfBytesToMap . , .

. .

- , . , , CreateFileMapping(). OpenFileMapping(). MapViewOfFile() .

 

 

: Linux Windows. : . Enter :

, ();

, , / ;

;

;

..

. . , .

 

 

4

: , .

 

Linux Windows. , ( Windows, fibers), . .

 

Linux

Linux (lightweight process, LWP). , , . , , : , . , .

, . , . .

Linux , , . - pthreads (POSIX threads), :

int pthread_create(pthread_t *thread, pthread_attr_t *attr, void * (*start_routine)(void *), void *arg);

 

:

thread , ;

attr ;

start_routine . void * start_routine(void *). ;

arg , . - , . .

pthread_exit().

, . pthread_join(). , .

pthread_join() , , , , . .

, : . , .. 2. :

pthread_mutex_init ;

pthread_mutex_lock . , , ;

pthread_mutex_unlock ;

pthread_mutex_trylock , pthread_mutex_lock , , EBUSY;

pthread_mutex_destroy .

 

Windows

Windows Linux. , . , . , , .. , . , main(), WinMain() .. , ExitProcess(), .

Windows, , Linux. Windows . WinAPI:

HANDLE CreateThread(PSECURITY_ATTRIBUTES lpThreadAttributes, DWORD dwStackSize, PTHREAD_START_ROUTINE lpStartAddress, PVOID lpParameter, DWORD dwCreationFlags, PDWORD lpThreadId);

:

lpThreadAttributes ;

dwStackSize , ;

lpStartAddress , DWORD WINAPI ThreadFunc(PVOID pvParam);

lpParameter , ;

dwCreationFlags ( );

lpThreadId , .

:

;

ExitThread();

( ) TerminateThread();

, , .

, CreateThread() , C/C++ (errno, strok, strerror ..). _beginthreadex _endthreadex, , .

Windows , , , . , .[2]

, pthreads. :

InitializeCriticalSection ;

EnterCriticalSection . . - , ;

LeaveCriticalSection ;

TryEnterCriticalSection . EnterCriticalSection(). , 0, ;

DeleteCriticalSection .

: Linux Windows. 2.3 2, .

 

 

5

: ; , .

 





:


: 2016-03-28; !; : 1124 |


:

:

,
==> ...

1807 - | 1566 -


© 2015-2024 lektsii.org - -

: 0.052 .