Java知识分享网 - 轻松学习从此开始!    

Java知识分享网

Java1234官方群25:java1234官方群17
Java1234官方群25:838462530
        
SpringBoot+SpringSecurity+Vue+ElementPlus权限系统实战课程 震撼发布        

最新Java全栈就业实战课程(免费)

springcloud分布式电商秒杀实战课程

IDEA永久激活

66套java实战课程无套路领取

锋哥开始收Java学员啦!

Python学习路线图

锋哥开始收Java学员啦!

MonetDB的gdk_system.c分析 PDF 下载


分享到:
时间:2021-11-12 10:51来源:http://www.java1234.com 作者:转载  侵权举报
MonetDB的gdk_system.c分析 PDF 下载
失效链接处理
MonetDB的gdk_system.c分析  PDF 下载



本站整理下载:
提取码:8d0q 
 
 
相关截图:
 
主要内容:

在代码的头部注释解释了gdk_system.c的实现作用。
This file contains a wrapper layer for threading, hence the underscore convention MT_x (Multi-Threading).  As all platforms that MonetDB runs on now support POSIX Threads (pthreads), this wrapping layer has become rather thin.
这是thread的wrapper层,所有thread转为MT_x封装。Monetdb支持POSIX的threads(就是pthreads)
  In the late 1990s when multi-threading support was introduced in MonetDB, pthreads was just emerging as a standard API and not widely adopted yet.  The earliest MT implementation focused on SGI Unix and provided multi- threading using multiple processses, and shared memory.
在1990年,monetdb支持了多线程。Pthreads作为标准api,早期MT实现采用SGI Unix,采用共享内存的多进程,
One of the relics of this model, namely the need to pre-allocate locks and semaphores, and consequently a maximum number of them, has been removed in the latest iteration of this layer.
模型最大的问题是预先分配锁和信号量,因此有一个最大的数量,这在最新的迭代版本中已经移除。
 
2数据结构分析
 
在gdk_system.h中,定义了锁、信号量数据结构,每个锁、信号量都增加了name用于标识。
 
typedef struct MT_Lock {
pthread_mutex_t lock;
char name[MT_NAME_LEN];
#ifdef LOCK_STATS
size_t count;
ATOMIC_TYPE contention;
ATOMIC_TYPE sleep;
struct MT_Lock *volatile next;
struct MT_Lock *volatile prev;
const char *locker;
const char *thread;
#endif
} MT_Lock;
 
/* this is the normal implementation of our pthreads-based read-write lock */
typedef struct MT_RWLock {
pthread_rwlock_t lock;
char name[MT_NAME_LEN];
} MT_RWLock;
 
typedef struct {
sem_t sema;
char name[MT_NAME_LEN];
} MT_Sema;
 
在gdk_system.c中定义了线程数据结构,主线程数据结构。把线程封装起来,同时记录线程的状态、线程的依赖关系。 程序采用宏定义的方式区分win和linux中的线程实现。
static struct winthread {
struct winthread *next;
HANDLE hdl;
DWORD tid;
void (*func) (void *);
void *data;
MT_Lock *lockwait; /* lock we're waiting for */
MT_Sema *semawait; /* semaphore we're waiting for */
struct winthread *joinwait; /* process we are joining with */
const char *working; /* what we're currently doing */
char algorithm[512]; /* the algorithm used in the last operation */
size_t algolen; /* length of string in .algorithm */
ATOMIC_TYPE exited;
bool detached:1, waiting:1;
char threadname[MT_NAME_LEN];
QryCtx *qry_ctx;
} *winthreads = NULL;
static struct winthread mainthread = {
.threadname = "main thread",
.exited = ATOMIC_VAR_INIT(0),
};
static CRITICAL_SECTION winthread_cs;
static DWORD threadslot = TLS_OUT_OF_INDEXES;

 

------分隔线----------------------------

锋哥公众号


锋哥微信


关注公众号
【Java资料站】
回复 666
获取 
66套java
从菜鸡到大神
项目实战课程

锋哥推荐