亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲精品老司机| 国产亚洲一二三区| 亚洲第一综合色| 欧美精品在线一区二区三区| 亚洲午夜私人影院| 欧美巨大另类极品videosbest | 欧美成人三级在线| 国产中文一区二区三区| 国产精品沙发午睡系列990531| www.日本不卡| 亚洲国产综合91精品麻豆| 欧美精品高清视频| 精品一区二区免费| 国产精品国产馆在线真实露脸| 色综合天天性综合| 三级欧美在线一区| 2020日本不卡一区二区视频| 成人av在线一区二区三区| 一级中文字幕一区二区| 欧美一区二区三区日韩| 国产成人午夜片在线观看高清观看| 国产精品高潮久久久久无| 在线亚洲一区观看| 免费视频最近日韩| 久久久www免费人成精品| 99re8在线精品视频免费播放| 亚洲成av人片在www色猫咪| 精品国产伦一区二区三区观看方式| 成人免费视频一区二区| 亚洲国产精品欧美一二99| 日韩久久久精品| 99精品久久只有精品| 蜜桃av一区二区三区| 中文字幕一区二区三区色视频| 欧美性猛交xxxx黑人交| 国产一二三精品| 午夜精品久久久久久| 国产欧美精品日韩区二区麻豆天美| 在线视频国内一区二区| 狠狠狠色丁香婷婷综合久久五月| 亚洲美女一区二区三区| 久久午夜电影网| 欧美精品三级日韩久久| 99精品热视频| 国产一区二区三区香蕉| 亚洲h在线观看| 玉米视频成人免费看| 久久久精品天堂| 日韩色视频在线观看| 在线观看成人免费视频| thepron国产精品| 国产一区日韩二区欧美三区| 丝袜亚洲精品中文字幕一区| 亚洲美女屁股眼交| 欧美经典一区二区| 久久天天做天天爱综合色| 欧美一级黄色大片| 欧美精品九九99久久| 欧美色综合天天久久综合精品| 99麻豆久久久国产精品免费| 国产精品一二一区| 久久丁香综合五月国产三级网站| 天堂成人国产精品一区| 亚洲福利视频导航| 性做久久久久久| 亚洲成人一区二区| 亚洲香蕉伊在人在线观| 亚洲一区二区欧美日韩| 亚洲香肠在线观看| 99re66热这里只有精品3直播| 一区二区三区在线观看欧美| 一区在线观看免费| 国产精品―色哟哟| 中文在线资源观看网站视频免费不卡| 精品国产一区二区三区久久久蜜月 | 欧美激情中文字幕一区二区| 精品国产一区久久| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 亚洲一区二区三区四区的| 日韩一区中文字幕| 中文字幕一区二区三区四区不卡 | 国产美女精品人人做人人爽| 韩国精品主播一区二区在线观看| 精品在线免费观看| 国产盗摄女厕一区二区三区| 国产91精品一区二区麻豆亚洲| 岛国一区二区在线观看| 成人激情电影免费在线观看| 91首页免费视频| 欧美亚洲国产一区二区三区va| 欧美美女激情18p| 欧美哺乳videos| 欧美激情中文字幕| 亚洲最大成人综合| 免费观看一级特黄欧美大片| 国产精品99久久久久| 成人a级免费电影| 欧洲视频一区二区| 日韩午夜在线观看| 欧美韩日一区二区三区| 一区二区三区成人| 蜜臀av性久久久久蜜臀aⅴ流畅 | 欧美一区二区观看视频| 日韩激情中文字幕| 国产精品美女久久久久久久久 | 久久天天做天天爱综合色| 国产精品欧美一级免费| 亚洲午夜羞羞片| 精品一区二区国语对白| 一本大道久久a久久综合| 欧美一区二区私人影院日本| 国产免费久久精品| 香蕉加勒比综合久久| 国产成人在线免费观看| 欧美亚洲自拍偷拍| 国产亚洲一区二区三区在线观看| 亚洲欧美另类久久久精品2019| 蜜臀久久99精品久久久久宅男 | 美女www一区二区| 成人免费视频一区二区| 69p69国产精品| 亚洲色图一区二区三区| 美女一区二区视频| 色噜噜偷拍精品综合在线| 久久无码av三级| 亚洲bdsm女犯bdsm网站| caoporm超碰国产精品| 精品国产百合女同互慰| 亚洲二区在线观看| 99久久综合精品| 精品国产髙清在线看国产毛片| 亚洲精品日韩专区silk| 国产原创一区二区| 欧美精品亚洲二区| 亚洲女人的天堂| 国产不卡视频一区二区三区| 欧美电影在线免费观看| 亚洲免费在线视频| 成人午夜在线视频| 久久久久久久电影| 开心九九激情九九欧美日韩精美视频电影| 色综合久久久网| 欧美韩国日本一区| 国产成人丝袜美腿| 久久久久久毛片| 久久草av在线| 日韩欧美国产综合| 日韩成人一级片| 337p亚洲精品色噜噜噜| 亚洲高清视频中文字幕| 99精品视频在线免费观看| 色婷婷国产精品综合在线观看| 91在线观看一区二区| 久久久另类综合| 国产另类ts人妖一区二区| 日韩欧美一级片| 日本不卡视频一二三区| 在线免费观看日本欧美| 亚洲美女免费在线| 91黄色免费观看| 亚洲精品国产一区二区三区四区在线 | 国产盗摄一区二区| 国产亚洲综合色| 成人性色生活片免费看爆迷你毛片| 久久久久99精品一区| 国产乱码精品一区二区三区av | 欧美日韩精品系列| 亚洲成人av在线电影| 欧美喷潮久久久xxxxx| 日韩电影一二三区| 日韩丝袜美女视频| 国产一区久久久| 国产精品久久免费看| 99视频在线观看一区三区| 中文字幕巨乱亚洲| 色综合久久中文综合久久97| 樱花草国产18久久久久| 欧美日韩亚洲另类| 美国毛片一区二区三区| 精品国产乱码久久久久久1区2区| 黄一区二区三区| 国产精品国产自产拍在线| 色综合天天综合网国产成人综合天| 亚洲人123区| 69堂亚洲精品首页| 国产精品羞羞答答xxdd| 亚洲日本va午夜在线影院| 色综合天天综合给合国产| 五月天激情小说综合| 26uuu国产电影一区二区| 国产成人h网站| 亚洲综合久久av| 精品国产制服丝袜高跟| 成人免费电影视频| 香蕉久久一区二区不卡无毒影院 | 97久久精品人人爽人人爽蜜臀| 亚洲色图欧美在线| 日韩亚洲欧美一区| av中文字幕在线不卡| 日韩中文字幕麻豆|