[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Jun 8, 2020. It is now read-only.
/ qac Public archive

shared memory atomic counter for q on linux

License

Notifications You must be signed in to change notification settings

jaeheum/qac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Title: README

Date: 20161031

# qac

Qac provides shared memory atomic counter to multiple q processes on Linux. These processes can be either parent/children or unrelated.

# Contents

Copyright and License

Example

API

Installation

Implementation Details and Bugs

# Copyright and License
Copyright (c) 2016 Jaeheum Han <jay.han@gmail.com>
Licensed under Apache License v2.0 - see LICENSE file for details 
# Example
q)\l qac.q
q)c:init 0;n:123456789
q)do[n;inc c];print c
123456789
q)do[n;dec c];0~print c
1b
q)
# API
o:.z.i; do[.z.c;if[o~.z.i;pids,:fork[]]]; ... ; wait[]
wait[] / blocks until all fork[]ed children are dead
kill[pids] / kill all pids
c:init j / c~(kc(-KJ);kj(intptr_t))
c:restart fname / `:/dev/rszshm_xxxxxx/0 or fname c
f:fname c / f~`:/dev/rszshm_xxxxxx/0 (useful for restart f)
detach c / detach c from current process, all ops but fname and rm are no-ops afterwards
rm c / rm the underlying shm file, preventing future processes from accessing it
xx:inc,dec,print c / xx:the value of counter, or nothing after detach or rm

For better performance ignore return values of inc/dec, and print afterwards (see demo.q).

## Opaque type

Treat counter or the return value of init and restart as opaque type.

# Installation

make install copies qac.so and rszshm.o to ~/q/l64 and qac.q to ~/q/.

Note makefile assumes that

  • kdb+ version > 3.0 on 64-bit linux (l64) with gcc
    • add -m32 flag and change l64 to l32 for 32-bit
  • q and c.o are installed in ~/q/l64
  • k.h is in ~/q/c/
# Implementation Details and Bugs

See notes.md.

This documentation was generated from qac/README.txt using Gitdown

About

shared memory atomic counter for q on linux

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published