亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? shared_memory.h

?? 簡單的動態內存管理程序源代碼
?? H
?? 第 1 頁 / 共 3 頁
字號:
// file: shared_memory.h// author: Marc Bumble// May 22, 2000// Page memory source for shared memory // Copyright (C) 2000 by Marc D. Bumble//  This program is free software; you can redistribute it and/or//  modify it under the terms of the GNU General Public License//  as published by the Free Software Foundation; either version 2//  of the License, or (at your option) any later version.//  This program is distributed in the hope that it will be useful,//  but WITHOUT ANY WARRANTY; without even the implied warranty of//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//  GNU General Public License for more details.//  You should have received a copy of the GNU General Public License//  along with this program; if not, write to the Free Software//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.#ifndef SHARED_MEMORY_H#define SHARED_MEMORY_Hextern "C" {#include <fcntl.h>              // for shm_open()#include <sys/mman.h>           // for shm_open()#include <sys/types.h>		// for shared memory shmget(),shmat(),ftok(),semop#include <unistd.h>		// for fork(),getpid(),getppid(), shm_open()#include <sys/sem.h>            // for semop}#include <iostream>#include <string>#include <fstream>              // for std::ofstream to()#include <sstream>		// string stream for stringstream#include <cerrno>#include <cstdlib>// #include <vector>#include <map>#include <alloc_exceptions.h>#include <allocator_bit_vector.h>#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)/* union semun is defined by including <sys/sem.h> */#else/* according to X/OPEN we have to define it ourselves */union semun {  int val;                    /* value for SETVAL */  struct semid_ds *buf;       /* buffer for IPC_STAT, IPC_SET */  unsigned short int *array;  /* array for GETALL, SETALL */  struct seminfo *__buf;      /* buffer for IPC_INFO */};#endifnamespace mem_space {//   enum allocator_t {sharedpooled, persistentpooled};  enum {name_length=512};  // key string for ftok(), the filename  typedef const char* allocator_key_t;  // address process uses to attach to shared memory  typedef const char* allocator_addr_t;  //  typedef const char* object_key_t;  ////////////////////////////////////////////////////////////////////  //////                             Memory Locks  ////////////////////////////////////////////////////////////////////  //////     //////    Locks are  mutual exclusion locks used  to protect process  //////    from  writing  simultaneously   to  shared  memory.   Each  //////    allocator will  get one semaphore set, and  then with that  //////    semaphore  set, each chunk  will individual  elements from  //////    that semaphore  set.  So each  chunk is has access  to the  //////    semid and  the semnum.  A  semid is common for  all chunks  //////    within a given allocator, and then each of the allocator's  //////    chunks will have its own individual semnum which indicates  //////    which semaphore in the semid array.  //////      ////////////////////////////////////////////////////////////////////  class locks {    enum {      num_of_arrays=128,      num_in_array=250    };    int semid;  public:    // constructor    locks(const mem_space::allocator_key_t& alloc_key,	  const int& proj_id);    // destructor    virtual ~locks();    // copy constructor    locks(const locks& t);    // assignment operator    locks& operator=(const locks& t);    // equality operator    bool operator==(const locks& t);    int get_num_of_arrays() {return num_of_arrays;}    int get_num_in_array() {return num_in_array;}    void lock(int semnum);    void unlock(int semnum);    void print() const;  }; // class locks  ////////////////////////////////////////////////////////////////////////////////  //////                          Class Memory_Index  ////////////////////////////////////////////////////////////////////////////////  //////     //////    Class Memory_Index  is just an  aggregation of information  //////    about shared  memory segments.  This class  is designed to  //////    be  passed  back  and   forth  as  a  parameter  to  carry  //////    information.  //////      //////    memory_ptr  - a  pointer to  the beginning  of  the shared  //////                  memory segment  //////    segment_num - the segment number  //////    initialized - whether or not the segment is already in use  //////                  and initialized.  //////      ////////////////////////////////////////////////////////////////////////////////    class memory_index_t {    void* memory_ptr;		// pointer    to    returned   memory,				// address.//     void* chunklist_ptr;	// pointer to chunklist for an object.// 				// Needed  by   an  attaching  process// 				// which  must   make  sure  that  its// 				// allocators  point  to  the  correct// 				// chunklist.    char key[name_length];	// alloc_key  used to  retrieve shared				// memory segment    int proj_id;		// shared memory number for this alloc 				// key. proj_id == segment_num    bool initialized;		// false  if   only  one  attached  to                                // memory   true  if  more   than  one                                // process attached    int segment_page_num;	// start page within shared memory				// segment where chunk is located    int element_offset;		// offset  from   start  of  chunk  to				// element number    int global_starting_element_num;	// memory starts at element number.  public:    // constructor    //     memory_index_t(void* mem_ptr, int buff_num, bool init) {    memory_index_t(void* mem_ptr, int proj_id_val, bool init) {      memory_ptr=mem_ptr;//       chunklist_ptr=0;      for (int i=0; i < name_length; i++)	key[i]=0;      // proj_id identifies which  segment within the series specified      // by the alloc_key      proj_id=proj_id_val;		// proj_id == segment number      initialized=init;      // segment_page_num identifies which page within a given segment      // Chunks are allocated on inter segment page boundaries.      segment_page_num=-1;	// page number within shared mem segment	      element_offset=-1;      global_starting_element_num=-1;    }    memory_index_t(void* p,		   char* path_name, 		   int project_id,		   int shared_mem_page_num,		   int elem_offset,		   int global_start_elem_num) {      memory_ptr=p;//       chunklist_ptr=0;      strcpy(key,path_name);      proj_id=project_id;      initialized=true;      segment_page_num=shared_mem_page_num;		      element_offset=elem_offset;      global_starting_element_num=global_start_elem_num;    }    memory_index_t(void) {      // initialize with null data      memory_ptr=0;//       chunklist_ptr=0;      // memset(key,0,name_length);      proj_id=-1;      initialized=false;      segment_page_num=-1;		      element_offset=-1;      global_starting_element_num=-1;    }    // destructor    virtual ~memory_index_t() {};    // copy constructor    memory_index_t(const memory_index_t& t) {      memory_ptr=t.memory_ptr;//       chunklist_ptr=t.chunklist_ptr;      proj_id=t.proj_id;      initialized=t.initialized;      strcpy(key,t.key);      segment_page_num=t.segment_page_num;      element_offset=t.element_offset;      global_starting_element_num=t.global_starting_element_num;    }    // assignment operator    memory_index_t& operator=(const memory_index_t& t) {      if (this != &t) {		// avoid self assignment: t=t	memory_ptr=t.memory_ptr;// 	chunklist_ptr=t.chunklist_ptr; 	proj_id=t.proj_id;	initialized=t.initialized;	strcpy(key,t.key);	segment_page_num=t.segment_page_num;	element_offset=t.element_offset;	global_starting_element_num=t.global_starting_element_num;      }      return *this;    }    void* get_memory_ptr(void) {return memory_ptr;}    void set_memory_ptr(void* val) {memory_ptr=val;}//     void* get_chunklist_ptr(void) {return chunklist_ptr;}//     void set_chunklist_ptr(void* val) {chunklist_ptr=val;}    int get_proj_id(void) {return proj_id;}//     int get_segment_num(void) {return proj_id;}    bool get_initialized(void) {return initialized;}    void set_proj_id(int val) {proj_id=val;}    void set_initialized(bool val) {initialized=val;}    void get_key(char* output) {strcpy(output,key);}    void set_key(char* input) {strcpy(key,input);}    void set_segment_page_num(int val) {segment_page_num=val;}		    int get_segment_page_num() {return segment_page_num;}		    void set_element_offset(int val) {element_offset=val;}    int get_element_offset() {return element_offset;}    void set_global_starting_element_num(int val)    {global_starting_element_num=val;}    int get_global_starting_element_num()    {return global_starting_element_num;}    void print() const {      std::clog << "Print: class memory_index_t() object:" << std::endl;      std::clog << "\tmemory_ptr: " << memory_ptr << std::endl;      std::clog << "\tkey: " << key << std::endl;      std::clog << "\tproj_id: " << proj_id << std::endl;      std::clog << "\tinitialized: " << initialized << std::endl;      std::clog << "\tsegment_page_num: " << segment_page_num << std::endl;      std::clog << "\telement_offset: " << element_offset << std::endl;      std::clog << "\tglobal_starting_element_num: " << global_starting_element_num<< std::endl;    }  }; // class memory_index_t  ////////////////////////////////////////////////////////////////////  //////                           Class map_index_t  ////////////////////////////////////////////////////////////////////  //////          //////        Class  map_index_t  is  used  to  store  and  retrieve  //////        pointers to chunk lists.   The Chunk list is stored in  //////        the  allocator's  Pool class  as  a static  attribute.  //////        Attaching  classes must  first initialize  their chunk  //////        list to point to  the correct address in shared memory  //////        so that these attaching allocators can access the same  //////        objects on the chunk list as the original allocator in  //////        the original process.  //////          ////////////////////////////////////////////////////////////////////    class map_index_t :    public memory_index_t {  private:    void* char_chunklist;    void* map_pr_chunklist;    void* map_chunklist;    void* container_chunklist;    void* object_chunklist;    pid_t creator_pid;    int ref_count;		// How many process refer to this object?  public:    // constructor    map_index_t(memory_index_t obj_idx,		void* str_chk_list,		void* map_pr_chk_list,		void* map_chk_list,		void* con_chk_list,		void* obj_chk_list,		pid_t pid) :      memory_index_t(obj_idx),      char_chunklist(str_chk_list),      map_pr_chunklist(map_pr_chk_list),      map_chunklist(map_chk_list),      container_chunklist(con_chk_list),      object_chunklist(obj_chk_list),      creator_pid(pid){      ref_count=0;    };    // constructor    map_index_t(memory_index_t mem_idx) :      memory_index_t(mem_idx) {      char_chunklist=0;      map_pr_chunklist=0;      map_chunklist=0;      container_chunklist=0;      object_chunklist=0;      creator_pid=0;      ref_count=0;    }    // constructor    map_index_t(void) :      memory_index_t() {      char_chunklist=0;      map_pr_chunklist=0;      map_chunklist=0;      container_chunklist=0;      object_chunklist=0;      creator_pid=0;      ref_count=0;    }    // destructor    virtual ~map_index_t() {          }    // copy constructor    map_index_t(const map_index_t& t) :      memory_index_t(t),      char_chunklist(t.char_chunklist),      map_pr_chunklist(t.map_pr_chunklist),      map_chunklist(t.map_chunklist),      container_chunklist(t.container_chunklist),      object_chunklist(t.object_chunklist),      creator_pid(t.creator_pid) {      ref_count=t.ref_count;    }    // assignment operator    map_index_t& operator=(const map_index_t& t)  {      // Shows example of superclass assignment      if (this != &t) {		// avoid self assignment: t=t	memory_index_t::operator=((memory_index_t&) t);  // do      superclass	// assignment first.	char_chunklist=t.char_chunklist;	map_pr_chunklist=t.map_pr_chunklist;	map_chunklist=t.map_chunklist;	container_chunklist=t.container_chunklist;	object_chunklist=t.object_chunklist;	creator_pid=t.creator_pid;	ref_count=t.ref_count;      }      return *this;    }    void* get_char_chunklist(void) {return char_chunklist;}    void set_char_chunklist(void* val) {char_chunklist=val;}    void* get_map_pr_chunklist(void) {return map_pr_chunklist;}    void set_map_pr_chunklist(void* val) {map_pr_chunklist=val;}    void* get_map_chunklist(void) {return map_chunklist;}    void set_map_chunklist(void* val) {map_chunklist=val;}    void* get_container_chunklist(void) {return container_chunklist;}    void set_container_chunklist(void* val) {container_chunklist=val;}    void* get_object_chunklist(void) {return object_chunklist;}    void set_object_chunklist(void* val) {object_chunklist=val;}    pid_t get_creator_pid(void) {return creator_pid;}    void set_creator_pid(pid_t val) {creator_pid=val;}    const int get_ref_count(void) {return ref_count;}    void increment_ref_count(void) {ref_count++;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久久久久亚洲伦| 午夜欧美视频在线观看| 欧美三级电影网站| 国产精品一区二区你懂的| 亚洲午夜日本在线观看| 久久久久久99精品| 欧美精品久久久久久久久老牛影院| 粉嫩嫩av羞羞动漫久久久 | av高清久久久| 精品一区在线看| 天天影视色香欲综合网老头| 毛片一区二区三区| 亚洲欧洲av一区二区三区久久| 日韩欧美久久久| 欧美军同video69gay| 色综合婷婷久久| 国产成人午夜视频| 久久草av在线| 日韩电影一二三区| 亚洲一本大道在线| 亚洲欧美日韩系列| 中文字幕中文字幕在线一区 | 欧美激情中文字幕| 久久一日本道色综合| 欧美一区二区精美| 欧美一区二区三区免费观看视频| 日本乱人伦aⅴ精品| 不卡的av网站| 成人黄色小视频在线观看| 精东粉嫩av免费一区二区三区| 午夜精品成人在线视频| 亚洲高清免费观看高清完整版在线观看 | 亚洲丝袜自拍清纯另类| 国产精品丝袜一区| 亚洲国产电影在线观看| 久久久久久一二三区| 精品99一区二区| 欧美精品一区视频| 久久一区二区三区四区| 国产亲近乱来精品视频| 国产欧美一区二区精品婷婷| 国产三区在线成人av| 久久精品亚洲乱码伦伦中文 | 欧美一卡二卡三卡| 欧美一区二区三区免费在线看 | 精品视频1区2区| 欧美日韩精品一二三区| 欧美日韩精品系列| 制服丝袜成人动漫| 亚洲综合视频在线观看| 一区二区视频免费在线观看| 一区二区日韩电影| 日韩影院在线观看| 麻豆国产欧美一区二区三区| 国产一区高清在线| 丁香一区二区三区| 色视频一区二区| 6080国产精品一区二区| 日韩精品一区二区三区中文精品| 精品成人免费观看| 国产欧美日韩一区二区三区在线观看| 中文幕一区二区三区久久蜜桃| 国产精品色呦呦| 亚洲一线二线三线视频| 美女视频黄 久久| 国产999精品久久久久久绿帽| 色综合久久99| 欧美二区三区的天堂| 日韩一区二区在线播放| 国产精品免费久久| 亚洲高清免费观看| 国产成人午夜电影网| 欧美视频一区二区三区在线观看| 欧美一二区视频| 国产精品第一页第二页第三页| 亚洲综合久久久| 狠狠色丁香婷婷综合久久片| av在线不卡网| 欧美一级二级三级蜜桃| 1024成人网| 美女在线视频一区| 成人国产精品免费网站| 欧美一区二区免费视频| 中文字幕在线一区二区三区| 日韩成人av影视| 99久久婷婷国产综合精品电影| 中文字幕一区二区三区在线不卡 | 5566中文字幕一区二区电影| 国产日韩欧美一区二区三区乱码| 一区二区激情视频| 国产精品一二三四区| 欧美伊人精品成人久久综合97| 久久久久国产精品麻豆| 日日摸夜夜添夜夜添国产精品| 成人精品国产一区二区4080| 91精品在线麻豆| 亚洲人成影院在线观看| 国产精品一区二区黑丝| 欧美日韩mp4| 亚洲人成小说网站色在线| 国产一二精品视频| 欧美日韩成人一区| 综合激情网...| 国内精品免费**视频| 欧美丰满少妇xxxbbb| 亚洲精品成人在线| 成人中文字幕在线| 精品少妇一区二区三区免费观看| 一区二区视频免费在线观看| 国产成人精品免费网站| 欧美精品一区男女天堂| 男人的j进女人的j一区| 欧美日韩专区在线| 亚洲精品中文字幕在线观看| 成人中文字幕在线| 久久久久九九视频| 国产伦精品一区二区三区视频青涩| 欧美日本一区二区三区| 亚洲综合一二三区| jlzzjlzz欧美大全| 欧美极品少妇xxxxⅹ高跟鞋| 久久国产生活片100| 欧美一级日韩一级| 日韩电影在线观看一区| 欧美日韩国产小视频在线观看| 亚洲美女一区二区三区| av一区二区三区| 1024国产精品| 91在线观看一区二区| 中文字幕一区二区在线观看| 福利一区福利二区| 国产精品福利一区| 波多野结衣中文字幕一区二区三区 | 在线看国产日韩| 亚洲卡通动漫在线| 欧美午夜理伦三级在线观看| 一二三区精品福利视频| 在线免费亚洲电影| 亚洲大片一区二区三区| 欧美日韩二区三区| 五月天精品一区二区三区| 欧美男人的天堂一二区| 免费视频一区二区| 欧美精品一区二区高清在线观看| 国内一区二区视频| 欧美激情一区二区| 91农村精品一区二区在线| 一区二区日韩电影| 91精品一区二区三区在线观看| 全部av―极品视觉盛宴亚洲| 中文字幕永久在线不卡| 在线观看精品一区| 爽好久久久欧美精品| 欧美xxx久久| 成人免费毛片高清视频| 亚洲人妖av一区二区| 欧美偷拍一区二区| 久99久精品视频免费观看| 久久久久久久综合狠狠综合| a级精品国产片在线观看| 夜夜嗨av一区二区三区四季av| 欧美喷水一区二区| 国内久久精品视频| 亚洲同性gay激情无套| 欧美日韩国产免费| 国产一区二区三区黄视频 | 日韩欧美国产高清| 国产成人精品综合在线观看| 亚洲欧美国产高清| 日韩一区二区精品葵司在线| 国产suv精品一区二区三区| 一区二区三区在线观看国产| 日韩欧美你懂的| 91在线国产观看| 美女在线视频一区| 亚洲色图在线视频| 精品人在线二区三区| 91麻豆成人久久精品二区三区| 亚洲mv大片欧洲mv大片精品| 久久麻豆一区二区| 欧美性受xxxx黑人xyx性爽| 国内精品自线一区二区三区视频| 亚洲蜜臀av乱码久久精品蜜桃| 欧美一区二区三区在线视频| 成人免费视频免费观看| 日韩中文字幕一区二区三区| 国产精品乱码久久久久久| 911精品国产一区二区在线| 成人午夜视频网站| 奇米四色…亚洲| 亚洲精品第一国产综合野| 国产亚洲欧美在线| 欧美老肥妇做.爰bbww| 91在线国产福利| 国产乱人伦偷精品视频不卡| 亚洲国产成人91porn| 中文字幕av一区 二区| 日韩一区二区三区av| 色综合视频一区二区三区高清| 国产美女一区二区三区|