Revision: 73054
http://sourceforge.net/p/brlcad/code/73054
Author: starseeker
Date: 2019-05-13 15:24:29 +0000 (Mon, 13 May 2019)
Log Message:
-----------
This is a (hopefully temporary) revert of r73012, with some rework as well
(semchk tries to check all files not just headers for semaphore definitions, PM
and TIE semahpores have been consolidated into the librt list). Once r73012 is
working reliably on Windows this should be reverted again to restore the
improved semaphore system.
Modified Paths:
--------------
brlcad/trunk/include/analyze.h
brlcad/trunk/include/bu/parallel.h
brlcad/trunk/include/photonmap.h
brlcad/trunk/include/rt/defines.h
brlcad/trunk/include/rt/resource.h
brlcad/trunk/src/adrt/librender/camera.c
brlcad/trunk/src/adrt/librender/camera.h
brlcad/trunk/src/burst/paint.c
brlcad/trunk/src/gtools/beset/fitness.c
brlcad/trunk/src/gtools/beset/fitness.h
brlcad/trunk/src/libanalyze/analyze_private.h
brlcad/trunk/src/libanalyze/api.c
brlcad/trunk/src/libbn/noise.c
brlcad/trunk/src/libbrep/PullbackCurve.cpp
brlcad/trunk/src/libbu/CMakeLists.txt
brlcad/trunk/src/libbu/datetime.c
brlcad/trunk/src/libbu/getcwd.c
brlcad/trunk/src/libbu/hash.c
brlcad/trunk/src/libbu/init.c
brlcad/trunk/src/libbu/list.c
brlcad/trunk/src/libbu/malloc.c
brlcad/trunk/src/libbu/parallel.c
brlcad/trunk/src/libbu/semaphore.c
brlcad/trunk/src/libged/check/check_adj_air.c
brlcad/trunk/src/libged/check/check_exp_air.c
brlcad/trunk/src/libged/check/check_gap.c
brlcad/trunk/src/libged/check/check_overlaps.c
brlcad/trunk/src/libged/check/check_unconf_air.c
brlcad/trunk/src/libged/gqa.c
brlcad/trunk/src/liboptical/photonmap.c
brlcad/trunk/src/librt/cache.c
brlcad/trunk/src/librt/db_open.c
brlcad/trunk/src/librt/prep.c
brlcad/trunk/src/librt/primitives/brep/brep.cpp
brlcad/trunk/src/librt/tree.c
brlcad/trunk/src/proc-db/pix2g.c
brlcad/trunk/src/rt/worker.c
Removed Paths:
-------------
brlcad/trunk/src/libbu/semaphore_register.cpp
Modified: brlcad/trunk/include/analyze.h
===================================================================
--- brlcad/trunk/include/analyze.h 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/include/analyze.h 2019-05-13 15:24:29 UTC (rev 73054)
@@ -50,8 +50,11 @@
/* Libanalyze return codes */
#define ANALYZE_OK 0x0000
#define ANALYZE_ERROR 0x0001 /**< something went wrong, function not completed
*/
+#define ANALYZE_SEM_WORKER RT_SEM_LAST
+#define ANALYZE_SEM_STATS ANALYZE_SEM_WORKER+1
+#define ANALYZE_SEM_LIST ANALYZE_SEM_STATS+1
+#define ANALYZE_SEM_LAST ANALYZE_SEM_LIST+1
-
/*
* Density specific structures
*/
Modified: brlcad/trunk/include/bu/parallel.h
===================================================================
--- brlcad/trunk/include/bu/parallel.h 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/include/bu/parallel.h 2019-05-13 15:24:29 UTC (rev 73054)
@@ -187,24 +187,19 @@
* because bu_log() acquires semaphore #0 (BU_SEM_SYSCALL).
*/
-/**
- *
- */
-BU_EXPORT extern int bu_semaphore_register(const char *name);
-
-/**
- *
- */
-#define BU_SEMAPHORE_DEFINE(x) x = bu_semaphore_register(CPP_STR(x))
-
/*
* Section for manifest constants for bu_semaphore_acquire()
*/
-extern int BU_SEM_GENERAL;
-extern int BU_SEM_SYSCALL;
-extern int BU_SEM_MAPPEDFILE;
-
-
+#define BU_SEM_SYSCALL 0
+#define BU_SEM_LISTS 1
+#define BU_SEM_BN_NOISE 2
+#define BU_SEM_MAPPEDFILE 3
+#define BU_SEM_THREAD 4
+#define BU_SEM_MALLOC 5
+#define BU_SEM_DATETIME 6
+#define BU_SEM_HASH 7
+#define BU_SEM_DIR 8
+#define BU_SEM_LAST (BU_SEM_DIR+1) /* allocate this many for LIBBU+LIBBN */
/*
* Automatic restart capability in bu_bomb(). The return from
* BU_SETJUMP is the return from the setjmp(). It is 0 on the first
Modified: brlcad/trunk/include/photonmap.h
===================================================================
--- brlcad/trunk/include/photonmap.h 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/include/photonmap.h 2019-05-13 15:24:29 UTC (rev 73054)
@@ -53,7 +53,6 @@
#define PM_SHADOW 2 /* Current not used */
#define PM_IMPORTANCE 3
-
/**
* Photon Map Data Structure
*/
Modified: brlcad/trunk/include/rt/defines.h
===================================================================
--- brlcad/trunk/include/rt/defines.h 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/include/rt/defines.h 2019-05-13 15:24:29 UTC (rev 73054)
@@ -179,7 +179,26 @@
# define RT_G_DEBUG RTG.debug
#endif
+/**
+ * Definition of global parallel-processing semaphores.
+ *
+ * res_syscall is now BU_SEM_SYSCALL
+ */
+#define RT_SEM_TREE0 (BU_SEM_LAST)
+#define RT_SEM_TREE1 (RT_SEM_TREE0+1)
+#define RT_SEM_TREE2 (RT_SEM_TREE1+1)
+#define RT_SEM_TREE3 (RT_SEM_TREE2+1)
+#define RT_SEM_WORKER (RT_SEM_TREE3+1)
+#define RT_SEM_STATS (RT_SEM_WORKER+1)
+#define RT_SEM_RESULTS (RT_SEM_STATS+1)
+#define RT_SEM_MODEL (RT_SEM_RESULTS+1)
+#define RT_SEM_CACHE (RT_SEM_MODEL+1)
+#define RT_SEM_PM (RT_SEM_CACHE+1)
+#define RT_SEM_TIE (RT_SEM_PM+1)
+#define RT_SEM_LAST (RT_SEM_TIE+1)
+
+
#define BACKING_DIST (-2.0) /**< @brief mm to look behind start
point */
#define OFFSET_DIST 0.01 /**< @brief mm to advance point into
box */
Modified: brlcad/trunk/include/rt/resource.h
===================================================================
--- brlcad/trunk/include/rt/resource.h 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/include/rt/resource.h 2019-05-13 15:24:29 UTC (rev 73054)
@@ -111,20 +111,6 @@
#define RT_CK_RESOURCE(_p) BU_CKMAG(_p, RESOURCE_MAGIC, "struct resource")
#define RT_RESOURCE_INIT_ZERO { RESOURCE_MAGIC, 0, BU_LIST_INIT_ZERO,
BU_PTBL_INIT_ZERO, 0, 0, 0, BU_LIST_INIT_ZERO, 0, 0, 0, BU_LIST_INIT_ZERO,
BU_LIST_INIT_ZERO, BU_LIST_INIT_ZERO, NULL, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0,
NULL, 0, 0, 0, 0, BU_PTBL_INIT_ZERO, NULL, 0, 0, 0, NULL, BU_PTBL_INIT_ZERO }
-/**
- * Definition of global parallel-processing semaphores.
- *
- * res_syscall is now BU_SEM_SYSCALL
- */
-RT_EXPORT extern int RT_SEM_WORKER;
-RT_EXPORT extern int RT_SEM_MODEL;
-RT_EXPORT extern int RT_SEM_RESULTS;
-RT_EXPORT extern int RT_SEM_TREE0;
-RT_EXPORT extern int RT_SEM_TREE1;
-RT_EXPORT extern int RT_SEM_TREE2;
-RT_EXPORT extern int RT_SEM_TREE3;
-
-
__END_DECLS
#endif /* RT_RESOURCE_H */
Modified: brlcad/trunk/src/adrt/librender/camera.c
===================================================================
--- brlcad/trunk/src/adrt/librender/camera.c 2019-05-13 15:23:13 UTC (rev
73053)
+++ brlcad/trunk/src/adrt/librender/camera.c 2019-05-13 15:24:29 UTC (rev
73054)
@@ -23,17 +23,14 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+
#include "bio.h"
-
#include "bu/parallel.h"
#include "bu/dylib.h"
-#include "bu/parallel.h"
-#include "bu/log.h"
-#include "bu/str.h"
+#include "raytrace.h" /* for RT_SEM_TIE semaphore */
-#include "./camera.h"
+#include "camera.h"
-
struct render_shader_s {
const char *name;
int (*init)(render_t *, const char *);
@@ -411,15 +408,15 @@
while (1) {
/* Determine if this scanline should be computed by this thread */
- bu_semaphore_acquire(td->sem_tie_worker);
+ bu_semaphore_acquire(RT_SEM_TIE);
if (*td->scanline == td->tile->size_y) {
- bu_semaphore_release(td->sem_tie_worker);
+ bu_semaphore_release(RT_SEM_TIE);
return;
} else {
scanline = *td->scanline;
(*td->scanline)++;
}
- bu_semaphore_release(td->sem_tie_worker);
+ bu_semaphore_release(RT_SEM_TIE);
v_scanline = scanline + td->tile->orig_y;
if (td->tile->format == RENDER_CAMERA_BIT_DEPTH_24) {
@@ -545,7 +542,6 @@
td.res_buf = &((char *)result->data)[result->ind];
scanline = 0;
td.scanline = &scanline;
- td.sem_tie_worker = bu_semaphore_register("sem_tie_worker");
bu_parallel(render_camera_render_thread, camera->thread_num, &td);
Modified: brlcad/trunk/src/adrt/librender/camera.h
===================================================================
--- brlcad/trunk/src/adrt/librender/camera.h 2019-05-13 15:23:13 UTC (rev
73053)
+++ brlcad/trunk/src/adrt/librender/camera.h 2019-05-13 15:24:29 UTC (rev
73054)
@@ -88,7 +88,6 @@
camera_tile_t *tile;
void *res_buf;
unsigned int *scanline;
- int sem_tie_worker;
} render_camera_thread_data_t;
Modified: brlcad/trunk/src/burst/paint.c
===================================================================
--- brlcad/trunk/src/burst/paint.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/burst/paint.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -127,9 +127,9 @@
for (y = gyorg; y < gyfin; y++) {
if (zoom != 1 && (y - gy) % zoom == 0)
continue;
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(RT_SEM_STATS);
(void) fb_read(fbiop, gxorg, y, (unsigned char *)pixbuf, cnt);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(RT_SEM_STATS);
for (x = gxorg; x < gxfin; x++) {
if (SAMERGB(&pixbuf[x-gxorg][0], pixexpendable)
) {
@@ -151,9 +151,9 @@
pixbuf[x-gxorg][BLU]);
#endif
}
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(RT_SEM_STATS);
(void) fb_write(fbiop, gxorg, y, (unsigned char *)pixbuf, cnt);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(RT_SEM_STATS);
#if DEBUG_CELLFB
brst_log("paintCellFb: fb_write(%d, %d)\n", x, y);
#endif
@@ -182,9 +182,9 @@
celldist = ap->a_cumlen/cellsz * zoom;
x = roundToInt(x + VDOT(ap->a_ray.r_dir, gridhor) * celldist);
y = roundToInt(y + VDOT(ap->a_ray.r_dir, gridver) * celldist);
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(RT_SEM_STATS);
err = fb_write(fbiop, x, y, pixel, 1);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(RT_SEM_STATS);
#if DEBUG_SPALLFB
brst_log("paintSpallFb:gridhor=<%g, %g, %g> gridver=<%g, %g, %g>\n",
gridhor[X], gridhor[Y], gridhor[Z],
Modified: brlcad/trunk/src/gtools/beset/fitness.c
===================================================================
--- brlcad/trunk/src/gtools/beset/fitness.c 2019-05-13 15:23:13 UTC (rev
73053)
+++ brlcad/trunk/src/gtools/beset/fitness.c 2019-05-13 15:24:29 UTC (rev
73054)
@@ -120,9 +120,9 @@
int status = 0;
if (partHeadp == NULL && fstate->ray[ap->a_user] == NULL) {
- bu_semaphore_acquire(fstate->sem_same);
+ bu_semaphore_acquire(SEM_SAME);
fstate->same += fstate->a_len;
- bu_semaphore_release(fstate->sem_same);
+ bu_semaphore_release(SEM_SAME);
return 0;
}
@@ -136,8 +136,8 @@
/* if both rays missed, count this as the same.
* no need to evaluate further*/
- bu_semaphore_acquire(fstate->sem_same);
- bu_semaphore_acquire(fstate->sem_diff);
+ bu_semaphore_acquire(SEM_SAME);
+ bu_semaphore_acquire(SEM_DIFF);
while (pp != partHeadp && mp != fstate->ray[ap->a_user]) {
if (status & STATUS_PP)
@@ -263,8 +263,8 @@
/* include trailing empty space as similar */
fstate->same += fstate->a_len - lastpt;
- bu_semaphore_release(fstate->sem_same);
- bu_semaphore_release(fstate->sem_diff);
+ bu_semaphore_release(SEM_SAME);
+ bu_semaphore_release(SEM_DIFF);
return 1;
}
@@ -288,12 +288,12 @@
get_next_row(struct fitness_state *fstate)
{
int r;
- bu_semaphore_acquire(fstate->sem_work);
+ bu_semaphore_acquire(SEM_WORK);
if (fstate->row < fstate->res[Y])
r = ++fstate->row; /* get a row to work on */
else
r = 0; /* signal end of work */
- bu_semaphore_release(fstate->sem_work);
+ bu_semaphore_release(SEM_WORK);
return r;
}
@@ -479,9 +479,6 @@
void
fit_prep(struct fitness_state *fstate, int rows, int cols)
{
- fstate->sem_work = bu_semaphore_register("beset_sem_work");
- fstate->sem_diff = bu_semaphore_register("beset_sem_diff");
- fstate->sem_same = bu_semaphore_register("beset_sem_same");
fstate->max_cpus = fstate->ncpu = 1;/*bu_avail_cpus();*/
fstate->capture = 0;
fstate->res[X] = rows;
Modified: brlcad/trunk/src/gtools/beset/fitness.h
===================================================================
--- brlcad/trunk/src/gtools/beset/fitness.h 2019-05-13 15:23:13 UTC (rev
73053)
+++ brlcad/trunk/src/gtools/beset/fitness.h 2019-05-13 15:24:29 UTC (rev
73054)
@@ -37,7 +37,12 @@
#define STATUS_MP 2
#define STATUS_EMPTY 0
+#define SEM_WORK RT_SEM_LAST
+#define SEM_DIFF RT_SEM_LAST+1
+#define SEM_SAME RT_SEM_LAST+2
+#define TOTAL_SEMAPHORES SEM_SAME+1
+
struct part {
struct bu_list l;
fastf_t inhit_dist;
@@ -49,10 +54,6 @@
struct part **ray; /* internal representation of raytraced source */
struct rt_i *rtip; /* current objects to be raytraced */
- /* semaphores for parallel */
- int sem_work;
- int sem_diff;
- int sem_same;
struct resource resource[MAX_PSW]; /* memory resource for multi-cpu
processing */
int ncpu;
int max_cpus;
Modified: brlcad/trunk/src/libanalyze/analyze_private.h
===================================================================
--- brlcad/trunk/src/libanalyze/analyze_private.h 2019-05-13 15:23:13 UTC
(rev 73053)
+++ brlcad/trunk/src/libanalyze/analyze_private.h 2019-05-13 15:24:29 UTC
(rev 73054)
@@ -100,14 +100,10 @@
int v_axis; /* is being used for the U, V, or invariant vector
direction */
int i_axis;
- int sem_worker;
-
- /* sem_worker protects this */
+ /* ANALYZE_SEM_WORKER protects this */
int v; /* indicates how many "grid_size" steps in the v
direction have been taken */
- int sem_stats;
-
- /* sem_stats protects this */
+ /* ANALYZE_SEM_STATS protects this */
double *m_lenDensity;
double *m_len;
unsigned long *shots;
Modified: brlcad/trunk/src/libanalyze/api.c
===================================================================
--- brlcad/trunk/src/libanalyze/api.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libanalyze/api.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -82,8 +82,7 @@
if (!segs) /* unexpected */
return 0;
- if (PartHeadp->pt_forw == PartHeadp)
- return 1;
+ if (PartHeadp->pt_forw == PartHeadp) return 1;
/* examine each partition until we get back to the head */
@@ -108,10 +107,10 @@
VJOIN1(opt, ap->a_ray.r_pt, pp->pt_outhit->hit_dist, ap->a_ray.r_dir);
if (state->debug) {
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(ANALYZE_SEM_WORKER);
bu_vls_printf(state->debug_str, "%s %g->%g\n",
pp->pt_regionp->reg_name,
pp->pt_inhit->hit_dist, pp->pt_outhit->hit_dist);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(ANALYZE_SEM_WORKER);
}
if (state->analysis_flags & ANALYSIS_EXP_AIR) {
@@ -146,18 +145,18 @@
/* computing the mass of the objects */
if (state->analysis_flags & ANALYSIS_MASS) {
if (state->debug) {
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(ANALYZE_SEM_WORKER);
bu_vls_printf(state->debug_str, "Hit %s doing mass\n",
pp->pt_regionp->reg_name);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(ANALYZE_SEM_WORKER);
}
/* make sure mater index is within range of densities */
if (material_id < 0 && state->default_den == 0) {
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(ANALYZE_SEM_WORKER);
bu_vls_printf(state->log_str, "Density index %d on region %s is
not in density table.\nSet GIFTmater on region or add entry to density table\n",
pp->pt_regionp->reg_gmater,
pp->pt_regionp->reg_name); /* XXX this should do
something else */
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(ANALYZE_SEM_WORKER);
return ANALYZE_ERROR;
}
@@ -206,9 +205,9 @@
los = pp->pt_regionp->reg_los;
if (los < 1) {
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(ANALYZE_SEM_WORKER);
bu_vls_printf(state->log_str, "bad LOS (%d) on %s\n", los,
pp->pt_regionp->reg_name);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(ANALYZE_SEM_WORKER);
}
/* accumulate the total mass values */
@@ -217,7 +216,7 @@
prd = ((struct per_region_data *)pp->pt_regionp->reg_udata);
/* accumulate the per-region per-view mass values */
- bu_semaphore_acquire(state->sem_stats);
+ bu_semaphore_acquire(ANALYZE_SEM_STATS);
prd->r_lenDensity[state->i_axis] += val;
/* accumulate the per-object per-view mass values */
@@ -266,7 +265,7 @@
poi[Z] -= mass*cmass[Y]*cmass[Z];
}
}
- bu_semaphore_release(state->sem_stats);
+ bu_semaphore_release(ANALYZE_SEM_STATS);
}
}
@@ -294,7 +293,7 @@
}
{
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(ANALYZE_SEM_STATS);
/* factor in the normal vector to find how 'skew' the surface
is */
RT_HIT_NORMAL(inormal, pp->pt_inhit, pp->pt_inseg->seg_stp,
&(ap->a_ray), pp->pt_inflip);
VREVERSE(inormal, inormal);
@@ -312,7 +311,7 @@
prd->optr->o_area[state->curr_view] += (cell_area/icos);
prd->optr->o_area[state->curr_view] += (cell_area/ocos);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(ANALYZE_SEM_STATS);
}
}
@@ -321,7 +320,7 @@
struct per_region_data *prd = ((struct per_region_data
*)pp->pt_regionp->reg_udata);
ap->A_LEN += dist; /* add to total volume */
{
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(ANALYZE_SEM_STATS);
/* add to region volume */
prd->r_len[state->curr_view] += dist;
@@ -329,15 +328,16 @@
/* add to object volume */
prd->optr->o_len[state->curr_view] += dist;
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(ANALYZE_SEM_STATS);
}
if (state->debug) {
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(ANALYZE_SEM_WORKER);
bu_vls_printf(state->debug_str, "\t\tvol hit %s oDist:%g
objVol:%g %s\n",
pp->pt_regionp->reg_name, dist,
prd->optr->o_len[state->curr_view], prd->optr->o_name);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(ANALYZE_SEM_WORKER);
}
if (state->plot_volume) {
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
if (ap->a_user & 1) {
pl_color(state->plot_volume, 128, 255, 192); /* pale green
*/
} else {
@@ -345,6 +345,7 @@
}
pdv_3line(state->plot_volume, pt, opt);
+ bu_semaphore_release(BU_SEM_SYSCALL);
}
}
@@ -357,7 +358,7 @@
}
if (pp->pt_regionp->reg_aircode) {
- /* look for air first on shotlines */
+ /* look for air first on shotlines */
if (pp->pt_back == PartHeadp) {
if (state->analysis_flags & ANALYSIS_FIRST_AIR)
state->first_air_callback(&ap->a_ray, pp,
state->first_air_callback_data);
@@ -459,14 +460,14 @@
VJOIN1(ihit, rp->r_pt, ihitp->hit_dist, rp->r_dir);
if (state->analysis_flags & ANALYSIS_OVERLAPS) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(ANALYZE_SEM_LIST);
add_unique_pair(state->overlapList, reg1, reg2, depth, ihit);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(ANALYZE_SEM_LIST);
state->overlaps_callback(&ap->a_ray, pp, reg1, reg2, depth,
state->overlaps_callback_data);
} else {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(ANALYZE_SEM_WORKER);
bu_vls_printf(state->log_str, "overlap %s %s\n", reg1->reg_name,
reg2->reg_name);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(ANALYZE_SEM_WORKER);
}
/* XXX We should somehow flag the volume/mass calculations as invalid */
@@ -800,13 +801,13 @@
shot_cnt = 0;
while (1) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(ANALYZE_SEM_WORKER);
if (rectangular_grid_generator(&ap.a_ray, state->grid) == 1){
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(ANALYZE_SEM_WORKER);
break;
}
ap.a_user = (int)(state->grid->current_point / (state->grid->x_points));
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(ANALYZE_SEM_WORKER);
(void)rt_shootray(&ap);
if (state->aborted)
return;
@@ -818,11 +819,11 @@
* view and return. When all threads have been through here,
* we'll have returned to serial computation.
*/
- bu_semaphore_acquire(state->sem_stats);
+ bu_semaphore_acquire(ANALYZE_SEM_STATS);
state->shots[state->curr_view] += shot_cnt;
state->m_lenDensity[state->curr_view] += ap.A_LENDEN; /* add our
length*density value */
state->m_len[state->curr_view] += ap.A_LEN; /* add our volume value */
- bu_semaphore_release(state->sem_stats);
+ bu_semaphore_release(ANALYZE_SEM_STATS);
}
/**
@@ -1400,8 +1401,6 @@
}
/* initialize some stuff */
- state->sem_worker = bu_semaphore_register("analyze_sem_worker");
- state->sem_stats = bu_semaphore_register("analyze_sem_stats");
allocate_region_data(state, names);
grid.refine_flag = 0;
shoot_rays(state);
Modified: brlcad/trunk/src/libbn/noise.c
===================================================================
--- brlcad/trunk/src/libbn/noise.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libbn/noise.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -162,9 +162,6 @@
]
-static int sem_noise = 0;
-
-
void
bn_noise_init(void)
{
@@ -171,13 +168,10 @@
uint32_t i, j, k, temp;
uint32_t rndtabi = BN_RAND_TABSIZE - 1;
- if (!sem_noise)
- sem_noise = bu_semaphore_register("SEM_NOISE");
+ bu_semaphore_acquire(BU_SEM_BN_NOISE);
- bu_semaphore_acquire(sem_noise);
-
if (ht.hashTableValid) {
- bu_semaphore_release(sem_noise);
+ bu_semaphore_release(BU_SEM_BN_NOISE);
return;
}
@@ -207,7 +201,7 @@
ht.hashTableValid = 1;
- bu_semaphore_release(sem_noise);
+ bu_semaphore_release(BU_SEM_BN_NOISE);
CK_HT();
}
@@ -497,7 +491,7 @@
* the list to wait our turn to add what we want to the table.
*/
- bu_semaphore_acquire(sem_noise);
+ bu_semaphore_acquire(BU_SEM_BN_NOISE);
/* We search the list one more time in case the last process to
* hold the semaphore just created the table we were about to add
@@ -517,7 +511,7 @@
if (i >= etbl_next)
ep = build_spec_tbl(h, l, o);
- bu_semaphore_release(sem_noise);
+ bu_semaphore_release(BU_SEM_BN_NOISE);
return ep;
}
Modified: brlcad/trunk/src/libbrep/PullbackCurve.cpp
===================================================================
--- brlcad/trunk/src/libbrep/PullbackCurve.cpp 2019-05-13 15:23:13 UTC (rev
73053)
+++ brlcad/trunk/src/libbrep/PullbackCurve.cpp 2019-05-13 15:24:29 UTC (rev
73054)
@@ -258,8 +258,7 @@
int p = bu_parallel_id();
if (!locals_initialized[p]) {
- static int sem_pullback_init =
bu_semaphore_register("SEM_PULLBACK_INIT");
- bu_semaphore_acquire(sem_pullback_init);
+ bu_semaphore_acquire(BU_SEM_MALLOC);
rev_surface[p] = ON_RevSurface::New();
nurbs_surface[p] = ON_NurbsSurface::New();
extr_surface[p] = new ON_Extrusion();
@@ -267,7 +266,7 @@
sum_surface[p] = ON_SumSurface::New();
proxy_surface[p] = new ON_SurfaceProxy();
locals_initialized[p] = true;
- bu_semaphore_release(sem_pullback_init);
+ bu_semaphore_release(BU_SEM_MALLOC);
}
ON_Interval domSplits[2][2] = { { ON_Interval::EmptyInterval,
ON_Interval::EmptyInterval }, { ON_Interval::EmptyInterval,
ON_Interval::EmptyInterval }};
Modified: brlcad/trunk/src/libbu/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libbu/CMakeLists.txt 2019-05-13 15:23:13 UTC (rev
73053)
+++ brlcad/trunk/src/libbu/CMakeLists.txt 2019-05-13 15:24:29 UTC (rev
73054)
@@ -116,7 +116,6 @@
redblack.c
realpath.c
semaphore.c
- semaphore_register.cpp
sha1.c
simd.c
sort.c
@@ -153,22 +152,32 @@
# Define a pre-build test for libbu to check the semaphores in BRL-CAD's
headers for
# ordering issues
-#set(BCAD_HDRS_FILE "${CMAKE_CURRENT_BINARY_DIR}/brlcad_headers.txt")
-#file(REMOVE "${BCAD_HDRS_FILE}")
-#file(GLOB_RECURSE BCAD_HDRS "${CMAKE_SOURCE_DIR}/include/*.h*")
-#foreach(HDRF ${BCAD_HDRS})
-# if (NOT "${HDRF}" MATCHES ".*.svn.*")
-# file(APPEND "${BCAD_HDRS_FILE}" "${HDRF}\n")
-# endif (NOT "${HDRF}" MATCHES ".*.svn.*")
-#endforeach(HDRF ${BCAD_HDRS})
-#DISTCLEAN("${CMAKE_CURRENT_BINARY_DIR}/brlcad_headers.txt")
-#BRLCAD_ADDEXEC(semchk "tests/semchk.cxx" "" NO_INSTALL)
-#add_custom_command(
-# TARGET libbu PRE_BUILD
-# COMMAND $<TARGET_FILE:semchk> "${BCAD_HDRS_FILE}"
-# COMMENT "Validating BRL-CAD library semaphore definitions"
-# DEPENDS semchk
-# )
+set(BCAD_SRCS_FILE "${CMAKE_CURRENT_BINARY_DIR}/brlcad_srcs.txt")
+file(REMOVE "${BCAD_SRCS_FILE}")
+file(GLOB_RECURSE BCAD_HDRS "${CMAKE_SOURCE_DIR}/include/*.h*")
+foreach(HDRF ${BCAD_HDRS})
+ if (NOT "${HDRF}" MATCHES ".*.svn.*")
+ file(APPEND "${BCAD_SRCS_FILE}" "${HDRF}\n")
+ endif (NOT "${HDRF}" MATCHES ".*.svn.*")
+endforeach(HDRF ${BCAD_HDRS})
+file(GLOB_RECURSE BCAD_SRCS "${CMAKE_SOURCE_DIR}/src/*.c*")
+foreach(SRCF ${BCAD_SRCS})
+ if (NOT "${SRCF}" MATCHES ".*.svn.*")
+ if (NOT "${SRCF}" MATCHES ".*/other/*")
+ if (NOT "${SRCF}" MATCHES ".*/misc/*")
+ file(APPEND "${BCAD_SRCS_FILE}" "${SRCF}\n")
+ endif (NOT "${SRCF}" MATCHES ".*/misc/*")
+ endif (NOT "${SRCF}" MATCHES ".*/other/*")
+ endif (NOT "${SRCF}" MATCHES ".*.svn.*")
+endforeach(SRCF ${BCAD_SRCS})
+DISTCLEAN("${CMAKE_CURRENT_BINARY_DIR}/brlcad_srcs.txt")
+BRLCAD_ADDEXEC(semchk "tests/semchk.cxx" "" NO_INSTALL)
+add_custom_command(
+ TARGET libbu PRE_BUILD
+ COMMAND $<TARGET_FILE:semchk> "${BCAD_SRCS_FILE}"
+ COMMENT "Validating BRL-CAD semaphore definitions"
+ DEPENDS semchk
+ )
BRLCAD_ADDDATA(fix.6r vfont)
BRLCAD_ADDDATA(nonie.r.12 vfont)
Modified: brlcad/trunk/src/libbu/datetime.c
===================================================================
--- brlcad/trunk/src/libbu/datetime.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libbu/datetime.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -47,9 +47,7 @@
extern int gettimeofday(struct timeval *, void *);
#endif
-extern int BU_SEM_DATETIME;
-
void
bu_utctime(struct bu_vls *vls_gmtime, const int64_t time_val)
{
Modified: brlcad/trunk/src/libbu/getcwd.c
===================================================================
--- brlcad/trunk/src/libbu/getcwd.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libbu/getcwd.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -50,9 +50,7 @@
extern char *realpath(const char *, char *);
#endif
-extern int BU_SEM_DIR;
-
char *
bu_getcwd(char *buf, size_t size)
{
Modified: brlcad/trunk/src/libbu/hash.c
===================================================================
--- brlcad/trunk/src/libbu/hash.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libbu/hash.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -40,7 +40,6 @@
struct bu_hash_tbl {
uint32_t magic;
- int semaphore;
unsigned long mask;
unsigned long num_lists;
unsigned long num_entries;
@@ -48,7 +47,6 @@
};
#define BU_CK_HASH_TBL(_hp) BU_CKMAG(_hp, BU_HASH_TBL_MAGIC, "bu_hash_tbl")
-
HIDDEN unsigned long
_bu_hash(const uint8_t *key, size_t len)
{
@@ -64,9 +62,7 @@
return hash;
}
-
-HIDDEN int
-_nhash_keycmp(const uint8_t *k1, const uint8_t *k2, size_t key_len)
+HIDDEN int _nhash_keycmp(const uint8_t *k1, const uint8_t *k2, size_t key_len)
{
const uint8_t *c1 = k1;
const uint8_t *c2 = k2;
@@ -83,7 +79,6 @@
return match;
}
-
struct bu_hash_tbl *
bu_hash_create(unsigned long tbl_size)
{
@@ -125,8 +120,6 @@
*/
hsh_tbl->lists = (struct bu_hash_entry **)calloc(hsh_tbl->num_lists,
sizeof(struct bu_hash_entry *));
- hsh_tbl->semaphore = bu_semaphore_register("SEM_HASH");
-
hsh_tbl->num_entries = 0;
hsh_tbl->magic = BU_HASH_TBL_MAGIC;
@@ -133,7 +126,6 @@
return hsh_tbl;
}
-
void
bu_hash_destroy(struct bu_hash_tbl *hsh_tbl)
{
@@ -229,7 +221,7 @@
if (!key || key_len == 0)
return -1;
- bu_semaphore_acquire(hsh_tbl->semaphore);
+ bu_semaphore_acquire(BU_SEM_HASH);
/* Use key hash to get bin, add entry to bin list */
idx = _bu_hash(key, key_len) & hsh_tbl->mask;
@@ -278,7 +270,7 @@
/* finally do as asked, set the value */
hsh_entry->value = val;
- bu_semaphore_release(hsh_tbl->semaphore);
+ bu_semaphore_release(BU_SEM_HASH);
return ret;
}
@@ -293,11 +285,11 @@
BU_CK_HASH_TBL(hsh_tbl);
- bu_semaphore_acquire(hsh_tbl->semaphore);
+ bu_semaphore_acquire(BU_SEM_HASH);
/* If we don't have a key, no-op */
if (!key || key_len == 0) {
- bu_semaphore_release(hsh_tbl->semaphore);
+ bu_semaphore_release(BU_SEM_HASH);
return;
}
@@ -306,7 +298,7 @@
/* Nothing in bin, we're done */
if (!hsh_tbl->lists[idx]) {
- bu_semaphore_release(hsh_tbl->semaphore);
+ bu_semaphore_release(BU_SEM_HASH);
return;
}
@@ -333,7 +325,7 @@
}
}
- bu_semaphore_release(hsh_tbl->semaphore);
+ bu_semaphore_release(BU_SEM_HASH);
}
@@ -345,11 +337,11 @@
BU_CK_HASH_TBL(hsh_tbl);
- bu_semaphore_acquire(hsh_tbl->semaphore);
+ bu_semaphore_acquire(BU_SEM_HASH);
if (hsh_tbl->num_entries == 0) {
/* this table is empty */
- bu_semaphore_release(hsh_tbl->semaphore);
+ bu_semaphore_release(BU_SEM_HASH);
return (struct bu_hash_entry *)NULL;
}
@@ -364,18 +356,18 @@
if (!ec) {
for (l = 0; l < hsh_tbl->num_lists; l++) {
if (hsh_tbl->lists[l]) {
- bu_semaphore_release(hsh_tbl->semaphore);
+ bu_semaphore_release(BU_SEM_HASH);
return hsh_tbl->lists[l];
}
}
/* if we've got nothing (empty bins) we're "done" iterating - return
* NULL */
- bu_semaphore_release(hsh_tbl->semaphore);
+ bu_semaphore_release(BU_SEM_HASH);
return (struct bu_hash_entry *)NULL;
}
if (e && e->next) {
- bu_semaphore_release(hsh_tbl->semaphore);
+ bu_semaphore_release(BU_SEM_HASH);
return e->next;
}
@@ -385,17 +377,16 @@
idx++;
for (l = idx; l < hsh_tbl->num_lists; l++) {
if (hsh_tbl->lists[l]) {
- bu_semaphore_release(hsh_tbl->semaphore);
+ bu_semaphore_release(BU_SEM_HASH);
return hsh_tbl->lists[l];
}
idx++;
}
/* if we've got nothing by this point we've reached the end */
- bu_semaphore_release(hsh_tbl->semaphore);
+ bu_semaphore_release(BU_SEM_HASH);
return (struct bu_hash_entry *)NULL;
}
-
int
bu_hash_key(struct bu_hash_entry *e, uint8_t **key, size_t *key_len)
{
Modified: brlcad/trunk/src/libbu/init.c
===================================================================
--- brlcad/trunk/src/libbu/init.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libbu/init.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -38,16 +38,6 @@
#include "bu/app.h"
#include "bu/parallel.h"
-
-int BU_SEM_GENERAL;
-int BU_SEM_SYSCALL;
-int BU_SEM_BN_NOISE;
-int BU_SEM_MAPPEDFILE;
-int BU_SEM_THREAD;
-int BU_SEM_MALLOC;
-int BU_SEM_DATETIME;
-int BU_SEM_DIR;
-
/* The Visual C compiler pragmas needed for INITIALIZE specify a "read"
* attribute, which is conflicting with the system definition of read:
*
@@ -62,16 +52,6 @@
INITIALIZE(libbu)
{
char iwd[MAXPATHLEN] = {0};
-
- BU_SEMAPHORE_DEFINE(BU_SEM_GENERAL);
- BU_SEMAPHORE_DEFINE(BU_SEM_SYSCALL);
- BU_SEMAPHORE_DEFINE(BU_SEM_BN_NOISE);
- BU_SEMAPHORE_DEFINE(BU_SEM_MAPPEDFILE);
- BU_SEMAPHORE_DEFINE(BU_SEM_THREAD);
- BU_SEMAPHORE_DEFINE(BU_SEM_MALLOC);
- BU_SEMAPHORE_DEFINE(BU_SEM_DATETIME);
- BU_SEMAPHORE_DEFINE(BU_SEM_DIR);
-
bu_getiwd(iwd, MAXPATHLEN);
}
Modified: brlcad/trunk/src/libbu/list.c
===================================================================
--- brlcad/trunk/src/libbu/list.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libbu/list.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -26,7 +26,6 @@
#include "bu/malloc.h"
#include "bu/parallel.h"
-
struct bu_list *
bu_list_new(void)
{
@@ -87,7 +86,32 @@
}
}
+void
+bu_list_parallel_append(struct bu_list *headp, struct bu_list *itemp)
+{
+ bu_semaphore_acquire(BU_SEM_LISTS);
+ BU_LIST_INSERT(headp, itemp); /* insert before head = append
*/
+ bu_semaphore_release(BU_SEM_LISTS);
+}
+struct bu_list *
+bu_list_parallel_dequeue(struct bu_list *headp)
+{
+ for (;;) {
+ register struct bu_list *p;
+
+ bu_semaphore_acquire(BU_SEM_LISTS);
+ p = BU_LIST_FIRST(bu_list, headp);
+ if (BU_LIST_NOT_HEAD(p, headp)) {
+ BU_LIST_DEQUEUE(p);
+ bu_semaphore_release(BU_SEM_LISTS);
+ return p;
+ }
+ bu_semaphore_release(BU_SEM_LISTS);
+ }
+ /* NOTREACHED */
+}
+
void
bu_ck_list(const struct bu_list *hd, const char *str)
{
Modified: brlcad/trunk/src/libbu/malloc.c
===================================================================
--- brlcad/trunk/src/libbu/malloc.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libbu/malloc.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -43,9 +43,7 @@
extern int posix_memalign(void **, size_t, size_t);
#endif
-extern int BU_SEM_MALLOC;
-
/**
* this controls whether to semaphore protect malloc calls
*
Modified: brlcad/trunk/src/libbu/parallel.c
===================================================================
--- brlcad/trunk/src/libbu/parallel.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libbu/parallel.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -111,9 +111,7 @@
void parallel_cpp11thread(void (*func)(int, void *), size_t ncpu, void *arg);
#endif /* CPP11THREAD */
-extern int BU_SEM_THREAD;
-
typedef enum {
PARALLEL_GET = 0,
PARALLEL_PUT = 1
Modified: brlcad/trunk/src/libbu/semaphore.c
===================================================================
--- brlcad/trunk/src/libbu/semaphore.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libbu/semaphore.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -85,7 +85,6 @@
#endif
-
void
bu_semaphore_init(unsigned int nsemaphores)
{
Deleted: brlcad/trunk/src/libbu/semaphore_register.cpp
===================================================================
--- brlcad/trunk/src/libbu/semaphore_register.cpp 2019-05-13 15:23:13 UTC
(rev 73053)
+++ brlcad/trunk/src/libbu/semaphore_register.cpp 2019-05-13 15:24:29 UTC
(rev 73054)
@@ -1,38 +0,0 @@
-#include "common.h"
-
-#include <vector>
-
-#include "bu/str.h"
-#include "bu/parallel.h"
-
-
-static std::vector<const char *> &get_semaphores()
-{
- static std::vector<const char *> semaphores = {};
-
- return semaphores;
-}
-
-
-extern "C" int
-bu_semaphore_register(const char *name)
-{
- std::vector<const char *> &semaphores = get_semaphores();
-
- // printf("registering %s, have %zu\n", name, semaphores.size());
-
- for (size_t i = 0; i < semaphores.size(); ++i) {
- if (BU_STR_EQUAL(semaphores[i], name)) {
- // printf("re-registered %s = %zu\n", semaphores[i], i+1);
- return i;
- }
- }
-
- semaphores.push_back(name);
- size_t ret = semaphores.size();
-
- // printf("registered %s = %zu\n", semaphores[ret-1], ret);
-
- return ret;
-}
-
Modified: brlcad/trunk/src/libged/check/check_adj_air.c
===================================================================
--- brlcad/trunk/src/libged/check/check_adj_air.c 2019-05-13 15:23:13 UTC
(rev 73053)
+++ brlcad/trunk/src/libged/check/check_adj_air.c 2019-05-13 15:24:29 UTC
(rev 73054)
@@ -39,9 +39,9 @@
adj_air(const struct xray* ray, const struct partition *pp, point_t pt, void*
callback_data)
{
struct adj_air_context *context = (struct adj_air_context*) callback_data;
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(GED_SEM_LIST);
add_to_list(context->adjAirList, pp->pt_back->pt_regionp->reg_name,
pp->pt_regionp->reg_name, 0.0, pt);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(GED_SEM_LIST);
if (context->plot_adjair) {
double d = pp->pt_outhit->hit_dist - pp->pt_inhit->hit_dist;
Modified: brlcad/trunk/src/libged/check/check_exp_air.c
===================================================================
--- brlcad/trunk/src/libged/check/check_exp_air.c 2019-05-13 15:23:13 UTC
(rev 73053)
+++ brlcad/trunk/src/libged/check/check_exp_air.c 2019-05-13 15:24:29 UTC
(rev 73054)
@@ -20,6 +20,7 @@
#include "common.h"
+#include "bu/parallel.h"
#include "ged.h"
#include "../ged_private.h"
@@ -32,7 +33,7 @@
int expAir_color[3];
};
-HIDDEN void
+HIDDEN void
exposed_air(const struct partition *pp,
point_t last_out_point,
point_t pt,
@@ -41,13 +42,13 @@
{
struct exp_air_context *context = (struct exp_air_context*) callback_data;
/* this shouldn't be air */
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(GED_SEM_LIST);
add_to_list(context->exposedAirList,
pp->pt_regionp->reg_name,
(char *)NULL,
pp->pt_outhit->hit_dist - pp->pt_inhit->hit_dist,
last_out_point);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(GED_SEM_LIST);
if (context->plot_exp_air) {
bu_semaphore_acquire(BU_SEM_SYSCALL);
Modified: brlcad/trunk/src/libged/check/check_gap.c
===================================================================
--- brlcad/trunk/src/libged/check/check_gap.c 2019-05-13 15:23:13 UTC (rev
73053)
+++ brlcad/trunk/src/libged/check/check_gap.c 2019-05-13 15:24:29 UTC (rev
73054)
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
+#include "bu/parallel.h"
#include "ged.h"
#include "../ged_private.h"
@@ -40,9 +41,9 @@
{
struct gap_context *context = (struct gap_context*) callback_data;
/* we only want to report unique pairs */
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(GED_SEM_LIST);
add_to_list(context->gapList, pp->pt_regionp->reg_name,
pp->pt_back->pt_regionp->reg_name, gap_dist, pt);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(GED_SEM_LIST);
/* let's plot */
if (context->plot_gaps) {
Modified: brlcad/trunk/src/libged/check/check_overlaps.c
===================================================================
--- brlcad/trunk/src/libged/check/check_overlaps.c 2019-05-13 15:23:13 UTC
(rev 73053)
+++ brlcad/trunk/src/libged/check/check_overlaps.c 2019-05-13 15:24:29 UTC
(rev 73054)
@@ -52,8 +52,6 @@
FILE *plot_overlaps;
int overlap_color[3];
struct ged_check_plot *overlaps_overlay_plot;
- int sem_stats;
- int sem_lists;
};
@@ -65,9 +63,9 @@
struct overlap_list *new_op;
struct overlap_list *op;
- bu_semaphore_acquire(callbackdata->sem_stats);
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
callbackdata->noverlaps++;
- bu_semaphore_release(callbackdata->sem_stats);
+ bu_semaphore_release(BU_SEM_SYSCALL);
if (!callbackdata->rpt_overlap_flag) {
bu_vls_printf(_ged_current_gedp->ged_result_str,
@@ -83,13 +81,13 @@
*/
} else {
BU_GET(new_op, struct overlap_list);
- bu_semaphore_acquire(callbackdata->sem_stats);
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
for (BU_LIST_FOR(op, overlap_list, &(olist->l))) {
if ((BU_STR_EQUAL(reg1, op->reg1)) && (BU_STR_EQUAL(reg2,
op->reg2))) {
op->count++;
if (depth > op->maxdepth)
op->maxdepth = depth;
- bu_semaphore_release(callbackdata->sem_stats);
+ bu_semaphore_release(BU_SEM_SYSCALL);
bu_free((char *) new_op, "overlap list");
return;
}
@@ -113,7 +111,7 @@
new_op->maxdepth = depth;
new_op->count = 1;
BU_LIST_INSERT(&(olist->l), &(new_op->l));
- bu_semaphore_release(callbackdata->sem_stats);
+ bu_semaphore_release(BU_SEM_SYSCALL);
}
}
@@ -254,19 +252,21 @@
VJOIN1(ohit, ray->r_pt, ohitp->hit_dist, ray->r_dir);
if (context->overlaps_overlay_flag) {
- bu_semaphore_acquire(context->sem_stats);
+ bu_semaphore_acquire(GED_SEM_WORKER);
BN_ADD_VLIST(context->overlaps_overlay_plot->vbp->free_vlist_hd,
context->overlaps_overlay_plot->vhead, ihit, BN_VLIST_LINE_MOVE);
BN_ADD_VLIST(context->overlaps_overlay_plot->vbp->free_vlist_hd,
context->overlaps_overlay_plot->vhead, ohit, BN_VLIST_LINE_DRAW);
- bu_semaphore_release(context->sem_stats);
+ bu_semaphore_release(GED_SEM_WORKER);
}
- bu_semaphore_acquire(context->sem_lists);
+ bu_semaphore_acquire(GED_SEM_LIST);
check_log_overlaps(reg1->reg_name, reg2->reg_name, depth, ihit, ohit,
context);
- bu_semaphore_release(context->sem_lists);
+ bu_semaphore_release(GED_SEM_LIST);
if (context->plot_overlaps) {
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
pl_color(context->plot_overlaps, V3ARGS(context->overlap_color));
pdv_3line(context->plot_overlaps, ihit, ohit);
+ bu_semaphore_release(BU_SEM_SYSCALL);
}
}
@@ -314,8 +314,6 @@
callbackdata.overlapList = &overlapList;
callbackdata.overlaps_overlay_flag = options->overlaps_overlay_flag;
callbackdata.overlaps_overlay_plot = &check_plot;
- callbackdata.sem_stats = bu_semaphore_register("check_stats");
- callbackdata.sem_lists = bu_semaphore_register("check_lists");
/* register callback */
analyze_register_overlaps_callback(state, overlap, &callbackdata);
Modified: brlcad/trunk/src/libged/check/check_unconf_air.c
===================================================================
--- brlcad/trunk/src/libged/check/check_unconf_air.c 2019-05-13 15:23:13 UTC
(rev 73053)
+++ brlcad/trunk/src/libged/check/check_unconf_air.c 2019-05-13 15:24:29 UTC
(rev 73054)
@@ -33,7 +33,7 @@
double tolerance;
};
-HIDDEN void
+HIDDEN void
unconf_air(const struct xray *ray,
const struct partition *ipart,
const struct partition *opart,
@@ -51,14 +51,14 @@
return;
}
- bu_semaphore_acquire(BU_SEM_GENERAL);
-
+ bu_semaphore_acquire(GED_SEM_WORKER);
+
add_to_list(context->unconfAirList,
ipart->pt_regionp->reg_name,
opart->pt_regionp->reg_name,
depth,
ihit);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(GED_SEM_WORKER);
if (context->plot_unconf_air) {
bu_semaphore_acquire(BU_SEM_SYSCALL);
Modified: brlcad/trunk/src/libged/gqa.c
===================================================================
--- brlcad/trunk/src/libged/gqa.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/libged/gqa.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -133,15 +133,10 @@
int v_axis; /* is being used for the U, V, or invariant vector
direction */
int i_axis;
- int sem_lists;
- int sem_worker;
-
- /* sem_worker protects this */
+ /* GED_SEM_WORKER protects this */
int v; /* indicates how many "grid_size" steps in the v direction
have been taken */
- int sem_stats;
-
- /* sem_stats protects this */
+ /* GED_SEM_STATS protects this */
double *m_lenDensity;
double *m_len;
double *m_volume;
@@ -195,7 +190,7 @@
/* Access to these lists should be in sections
- * of code protected by state->sem_lists
+ * of code protected by GED_SEM_LIST
*/
/**
@@ -765,7 +760,7 @@
struct region *reg2,
struct partition *hp)
{
- struct cstate *state = (struct cstate *)ap->A_STATE;
+
struct xray *rp = &ap->a_ray;
struct hit *ihitp = pp->pt_inhit;
struct hit *ohitp = pp->pt_outhit;
@@ -792,30 +787,34 @@
VJOIN1(ohit, rp->r_pt, ohitp->hit_dist, rp->r_dir);
if (plot_overlaps) {
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
pl_color(plot_overlaps, V3ARGS(overlap_color));
pdv_3line(plot_overlaps, ihit, ohit);
+ bu_semaphore_release(BU_SEM_SYSCALL);
}
if (analysis_flags & ANALYSIS_PLOT_OVERLAPS) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
BN_ADD_VLIST(ged_gqa_plot.vbp->free_vlist_hd, ged_gqa_plot.vhead, ihit,
BN_VLIST_LINE_MOVE);
BN_ADD_VLIST(ged_gqa_plot.vbp->free_vlist_hd, ged_gqa_plot.vhead, ohit,
BN_VLIST_LINE_DRAW);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
if (analysis_flags & ANALYSIS_OVERLAPS) {
- bu_semaphore_acquire(state->sem_lists);
+ bu_semaphore_acquire(GED_SEM_LIST);
add_unique_pair(&overlapList, reg1, reg2, depth, ihit);
- bu_semaphore_release(state->sem_lists);
+ bu_semaphore_release(GED_SEM_LIST);
if (plot_overlaps) {
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
pl_color(plot_overlaps, V3ARGS(overlap_color));
pdv_3line(plot_overlaps, ihit, ohit);
+ bu_semaphore_release(BU_SEM_SYSCALL);
}
} else {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, "overlap %s %s\n",
reg1->reg_name, reg2->reg_name);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
/* XXX We should somehow flag the volume/weight calculations as invalid */
@@ -846,27 +845,26 @@
}
-void _gqa_exposed_air(struct application *ap,
- struct partition *pp,
- point_t last_out_point,
- point_t pt,
- point_t opt)
+void _gqa_exposed_air(struct partition *pp,
+ point_t last_out_point,
+ point_t pt,
+ point_t opt)
{
- struct cstate *state = (struct cstate *)ap->A_STATE;
-
/* this shouldn't be air */
- bu_semaphore_acquire(state->sem_lists);
+ bu_semaphore_acquire(GED_SEM_LIST);
add_unique_pair(&exposedAirList,
pp->pt_regionp,
(struct region *)NULL,
pp->pt_outhit->hit_dist - pp->pt_inhit->hit_dist, /* thickness */
last_out_point); /* location */
- bu_semaphore_release(state->sem_lists);
+ bu_semaphore_release(GED_SEM_LIST);
if (plot_expair) {
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
pl_color(plot_expair, V3ARGS(expAir_color));
pdv_3line(plot_expair, pt, opt);
+ bu_semaphore_release(BU_SEM_SYSCALL);
}
}
@@ -911,10 +909,10 @@
VJOIN1(opt, ap->a_ray.r_pt, pp->pt_outhit->hit_dist, ap->a_ray.r_dir);
if (debug) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, "%s %g->%g\n",
pp->pt_regionp->reg_name,
pp->pt_inhit->hit_dist, pp->pt_outhit->hit_dist);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
/* checking for air sticking out of the model. This is done
@@ -930,7 +928,7 @@
*/
if (pp->pt_regionp->reg_aircode &&
(air_first || gap_dist > overlap_tolerance)) {
- _gqa_exposed_air(ap, pp, last_out_point, pt, opt);
+ _gqa_exposed_air(pp, last_out_point, pt, opt);
} else {
air_first = 0;
}
@@ -947,13 +945,13 @@
if (gap_dist > overlap_tolerance) {
/* like overlaps, we only want to report unique pairs */
- bu_semaphore_acquire(state->sem_lists);
+ bu_semaphore_acquire(GED_SEM_LIST);
add_unique_pair(&gapList,
pp->pt_regionp,
pp->pt_back->pt_regionp,
gap_dist,
pt);
- bu_semaphore_release(state->sem_lists);
+ bu_semaphore_release(GED_SEM_LIST);
/* like overlaps, let's plot */
if (plot_gaps) {
@@ -960,8 +958,10 @@
vect_t gapEnd;
VJOIN1(gapEnd, pt, -gap_dist, ap->a_ray.r_dir);
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
pl_color(plot_gaps, V3ARGS(gap_color));
pdv_3line(plot_gaps, pt, gapEnd);
+ bu_semaphore_release(BU_SEM_SYSCALL);
}
}
}
@@ -970,18 +970,18 @@
/* computing the weight of the objects */
if (analysis_flags & ANALYSIS_WEIGHTS) {
if (debug) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, "Hit %s doing
weight\n", pp->pt_regionp->reg_name);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
/* make sure mater index is within range of densities */
if (pp->pt_regionp->reg_gmater < 0) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, "density index
%d on region %s is outside of range\nSet GIFTmater on region or add entry to
density table\n",
pp->pt_regionp->reg_gmater,
pp->pt_regionp->reg_name);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
return GED_ERROR;
} else {
@@ -1029,9 +1029,9 @@
los = pp->pt_regionp->reg_los;
if (los < 1) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, "bad LOS
(%d) on %s\n", los, pp->pt_regionp->reg_name);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
/* accumulate the total weight values */
@@ -1040,7 +1040,7 @@
prd = ((struct per_region_data *)pp->pt_regionp->reg_udata);
/* accumulate the per-region per-view weight values */
- bu_semaphore_acquire(state->sem_stats);
+ bu_semaphore_acquire(GED_SEM_STATS);
prd->r_lenDensity[state->i_axis] += val;
/* accumulate the per-object per-view weight values */
@@ -1090,7 +1090,7 @@
}
}
- bu_semaphore_release(state->sem_stats);
+ bu_semaphore_release(GED_SEM_STATS);
}
}
@@ -1099,7 +1099,7 @@
struct per_region_data *prd = ((struct per_region_data
*)pp->pt_regionp->reg_udata);
ap->A_LEN += dist; /* add to total volume */
{
- bu_semaphore_acquire(state->sem_stats);
+ bu_semaphore_acquire(GED_SEM_STATS);
/* add to region volume */
prd->r_len[state->curr_view] += dist;
@@ -1107,18 +1107,19 @@
/* add to object volume */
prd->optr->o_len[state->curr_view] += dist;
- bu_semaphore_release(state->sem_stats);
+ bu_semaphore_release(GED_SEM_STATS);
}
if (debug) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, "\t\tvol hit
%s oDist:%g objVol:%g %s\n",
pp->pt_regionp->reg_name, dist,
prd->optr->o_len[state->curr_view], prd->optr->o_name);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
if (plot_volume) {
VJOIN1(opt, ap->a_ray.r_pt, pp->pt_outhit->hit_dist,
ap->a_ray.r_dir);
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
if (ap->a_user & 1) {
pl_color(plot_volume, V3ARGS(gap_color));
} else {
@@ -1126,6 +1127,7 @@
}
pdv_3line(plot_volume, pt, opt);
+ bu_semaphore_release(BU_SEM_SYSCALL);
}
}
@@ -1138,16 +1140,19 @@
double d = pp->pt_outhit->hit_dist - pp->pt_inhit->hit_dist;
point_t aapt;
- bu_semaphore_acquire(state->sem_lists);
+ bu_semaphore_acquire(GED_SEM_LIST);
add_unique_pair(&adjAirList, pp->pt_back->pt_regionp,
pp->pt_regionp, 0.0, pt);
- bu_semaphore_release(state->sem_lists);
+ bu_semaphore_release(GED_SEM_LIST);
d *= 0.25;
VJOIN1(aapt, pt, d, ap->a_ray.r_dir);
+ bu_semaphore_acquire(BU_SEM_SYSCALL);
pl_color(plot_adjair, V3ARGS(adjAir_color));
pdv_3line(plot_adjair, pt, aapt);
+ bu_semaphore_release(BU_SEM_SYSCALL);
+
}
}
@@ -1164,7 +1169,7 @@
/* the last thing we hit was air. Make a note of that */
pp = PartHeadp->pt_back;
- _gqa_exposed_air(ap, pp, last_out_point, pt, opt);
+ _gqa_exposed_air(pp, last_out_point, pt, opt);
}
@@ -1197,7 +1202,7 @@
{
int v;
/* look for more work */
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
if (state->v < state->steps[state->v_axis])
v = state->v++; /* get a row to work on */
@@ -1204,7 +1209,7 @@
else
v = 0; /* signal end of work */
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
return v;
}
@@ -1250,9 +1255,9 @@
v_coord = v * gridSpacing;
if (debug) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, " v = %d
v_coord=%g\n", v, v_coord);
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
if ((v&1) || state->first) {
@@ -1266,10 +1271,10 @@
ap.a_ray.r_pt[state->i_axis] =
ap.a_rt_i->mdl_min[state->i_axis];
if (debug) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, "%5g %5g
%5g -> %g %g %g\n", V3ARGS(ap.a_ray.r_pt),
V3ARGS(ap.a_ray.r_dir));
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
ap.a_user = v;
(void)rt_shootray(&ap);
@@ -1289,10 +1294,10 @@
ap.a_ray.r_pt[state->i_axis] =
ap.a_rt_i->mdl_min[state->i_axis];
if (debug) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, "%5g %5g
%5g -> %g %g %g\n", V3ARGS(ap.a_ray.r_pt),
V3ARGS(ap.a_ray.r_dir));
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
ap.a_user = v;
(void)rt_shootray(&ap);
@@ -1302,13 +1307,12 @@
shot_cnt++;
- if (debug) {
+ if (debug)
if (u+1 < state->steps[state->u_axis]) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, "
---\n");
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
- }
}
}
@@ -1317,9 +1321,9 @@
}
if (debug && (u == -1)) {
- bu_semaphore_acquire(state->sem_worker);
+ bu_semaphore_acquire(GED_SEM_WORKER);
bu_vls_printf(_ged_current_gedp->ged_result_str, "didn't shoot any
rays\n");
- bu_semaphore_release(state->sem_worker);
+ bu_semaphore_release(GED_SEM_WORKER);
}
/* There's nothing else left to work on in this view. It's time
@@ -1327,11 +1331,11 @@
* view and return. When all threads have been through here,
* we'll have returned to serial computation.
*/
- bu_semaphore_acquire(state->sem_stats);
+ bu_semaphore_acquire(GED_SEM_STATS);
state->shots[state->curr_view] += shot_cnt;
state->m_lenDensity[state->curr_view] += ap.A_LENDEN; /* add our
length*density value */
state->m_len[state->curr_view] += ap.A_LEN; /* add our volume value */
- bu_semaphore_release(state->sem_stats);
+ bu_semaphore_release(GED_SEM_STATS);
}
@@ -2401,8 +2405,6 @@
if (options_prep(rtip, state.span) != GED_OK) return GED_ERROR;
/* initialize some stuff */
- state.sem_worker = bu_semaphore_register("gqa_sem_worker");
- state.sem_stats = bu_semaphore_register("gqa_sem_stats");
state.rtip = rtip;
state.first = 1;
allocate_per_region_data(&state, start_objs, argc, argv);
Modified: brlcad/trunk/src/liboptical/photonmap.c
===================================================================
--- brlcad/trunk/src/liboptical/photonmap.c 2019-05-13 15:23:13 UTC (rev
73053)
+++ brlcad/trunk/src/liboptical/photonmap.c 2019-05-13 15:24:29 UTC (rev
73054)
@@ -1079,15 +1079,11 @@
void
BuildIrradianceCache(int pid, struct PNode *Node, struct application *ap)
{
- static int sem_photonmap = 0;
- if (!sem_photonmap)
- sem_photonmap = bu_semaphore_register("sem_photonmap");
-
if (!Node)
return;
/* Determine if this pt will be used by calculating a weight */
- bu_semaphore_acquire(sem_photonmap);
+ bu_semaphore_acquire(RT_SEM_PM);
if (!Node->C) {
ICSize++;
Node->C++;
@@ -1095,10 +1091,10 @@
if (!(ICSize%(PMap[PM_GLOBAL]->MaxPhotons/8)))
bu_log(" Irradiance Cache Progress: %d%%\n",
(int)(0.5+100.0*ICSize/PMap[PM_GLOBAL]->MaxPhotons));
#endif
- bu_semaphore_release(sem_photonmap);
+ bu_semaphore_release(RT_SEM_PM);
Irradiance(pid, &Node->P, ap);
} else {
- bu_semaphore_release(sem_photonmap);
+ bu_semaphore_release(RT_SEM_PM);
}
BuildIrradianceCache(pid, Node->L, ap);
Modified: brlcad/trunk/src/librt/cache.c
===================================================================
--- brlcad/trunk/src/librt/cache.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/librt/cache.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -71,12 +71,11 @@
struct rt_cache {
char dir[MAXPATHLEN];
int read_only;
- int semaphore;
int (*log)(const char *format, ...);
int (*debug)(const char *format, ...);
struct bu_hash_tbl *entry_hash;
};
-#define CACHE_INIT {{0}, 0, 0, bu_log, NULL, NULL}
+#define CACHE_INIT {{0}, 0, bu_log, NULL, NULL}
HIDDEN void
@@ -331,8 +330,6 @@
/* initialize database instance pointer storage */
cache->entry_hash = bu_hash_create(1024);
- cache->semaphore = bu_semaphore_register("SEM_CACHE");
-
return 1;
}
@@ -410,17 +407,17 @@
if (!cache || !name)
return NULL;
- bu_semaphore_acquire(cache->semaphore);
+ bu_semaphore_acquire(RT_SEM_CACHE);
e = (struct rt_cache_entry *)bu_hash_get(cache->entry_hash, (const uint8_t
*)name, strlen(name));
if (e) {
- bu_semaphore_release(cache->semaphore);
+ bu_semaphore_release(RT_SEM_CACHE);
return e;
}
cache_get_objfile(cache, name, path, MAXPATHLEN);
if (!bu_file_exists(path, NULL)) {
- bu_semaphore_release(cache->semaphore);
+ bu_semaphore_release(RT_SEM_CACHE);
return NULL;
}
@@ -439,13 +436,13 @@
}
BU_PUT(e->ext, struct bu_external);
BU_PUT(e, struct rt_cache);
- bu_semaphore_release(cache->semaphore);
+ bu_semaphore_release(RT_SEM_CACHE);
return NULL;
}
e->ext->ext_buf = (uint8_t *)(e->mfp->buf);
bu_hash_set(cache->entry_hash, (const uint8_t *)name, strlen(name), e);
- bu_semaphore_release(cache->semaphore);
+ bu_semaphore_release(RT_SEM_CACHE);
return e;
}
Modified: brlcad/trunk/src/librt/db_open.c
===================================================================
--- brlcad/trunk/src/librt/db_open.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/librt/db_open.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -58,39 +58,12 @@
struct db_i *
db_open(const char *name, const char *mode)
{
- static int sem_uses = 0;
- extern int RT_SEM_WORKER;
- extern int RT_SEM_RESULTS;
- extern int RT_SEM_MODEL;
- extern int RT_SEM_TREE0;
- extern int RT_SEM_TREE1;
- extern int RT_SEM_TREE2;
- extern int RT_SEM_TREE3;
register struct db_i *dbip = DBI_NULL;
register int i;
char **argv;
- if (!sem_uses)
- sem_uses = bu_semaphore_register("LIBRT_SEM_USES");
+ if (name == NULL) return DBI_NULL;
- if (!RT_SEM_WORKER)
- RT_SEM_WORKER = bu_semaphore_register("RT_SEM_WORKER");
- if (!RT_SEM_RESULTS)
- RT_SEM_RESULTS = bu_semaphore_register("RT_SEM_RESULTS");
- if (!RT_SEM_MODEL)
- RT_SEM_MODEL = bu_semaphore_register("RT_SEM_MODEL");
- if (!RT_SEM_TREE0)
- RT_SEM_TREE0 = bu_semaphore_register("RT_SEM_TREE0");
- if (!RT_SEM_TREE1)
- RT_SEM_TREE1 = bu_semaphore_register("RT_SEM_TREE1");
- if (!RT_SEM_TREE2)
- RT_SEM_TREE2 = bu_semaphore_register("RT_SEM_TREE2");
- if (!RT_SEM_TREE3)
- RT_SEM_TREE3 = bu_semaphore_register("RT_SEM_TREE3");
-
- if (name == NULL)
- return DBI_NULL;
-
if (RT_G_DEBUG & DEBUG_DB) {
bu_log("db_open(%s, %s)\n", name, mode);
}
@@ -112,9 +85,9 @@
if (mfp->apbuf) {
dbip = (struct db_i *)mfp->apbuf;
RT_CK_DBI(dbip);
- bu_semaphore_acquire(sem_uses);
+ bu_semaphore_acquire(BU_SEM_LISTS);
dbip->dbi_uses++;
- bu_semaphore_release(sem_uses);
+ bu_semaphore_release(BU_SEM_LISTS);
/*
* decrement the mapped file reference counter by 1,
@@ -313,9 +286,6 @@
{
register int i;
register struct directory *dp, *nextdp;
- static int sem_uses = 0;
- if (!sem_uses)
- sem_uses = bu_semaphore_register("LIBRT_SEM_USES");
if (!dbip)
return;
@@ -324,13 +294,13 @@
if (RT_G_DEBUG&DEBUG_DB) bu_log("db_close(%s) %p uses=%d\n",
dbip->dbi_filename, (void *)dbip,
dbip->dbi_uses);
- bu_semaphore_acquire(sem_uses);
+ bu_semaphore_acquire(BU_SEM_LISTS);
if ((--dbip->dbi_uses) > 0) {
- bu_semaphore_release(sem_uses);
+ bu_semaphore_release(BU_SEM_LISTS);
/* others are still using this database */
return;
}
- bu_semaphore_release(sem_uses);
+ bu_semaphore_release(BU_SEM_LISTS);
/* ready to free the database -- use count is now zero */
@@ -440,15 +410,11 @@
struct db_i *
db_clone_dbi(struct db_i *dbip, long int *client)
{
- static int sem_uses = 0;
- if (!sem_uses)
- sem_uses = bu_semaphore_register("LIBRT_SEM_USES");
-
RT_CK_DBI(dbip);
- bu_semaphore_acquire(sem_uses);
+ bu_semaphore_acquire(BU_SEM_LISTS);
dbip->dbi_uses++;
- bu_semaphore_release(sem_uses);
+ bu_semaphore_release(BU_SEM_LISTS);
if (client) {
bu_ptbl_ins_unique(&dbip->dbi_clients, client);
}
Modified: brlcad/trunk/src/librt/prep.c
===================================================================
--- brlcad/trunk/src/librt/prep.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/librt/prep.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -50,15 +50,6 @@
HIDDEN void rt_solid_bitfinder(register union tree *treep, struct region
*regp, struct resource *resp);
-int RT_SEM_WORKER = 0;
-int RT_SEM_RESULTS = 0;
-int RT_SEM_MODEL = 0;
-int RT_SEM_TREE0 = 0;
-int RT_SEM_TREE1 = 0;
-int RT_SEM_TREE2 = 0;
-int RT_SEM_TREE3 = 0;
-
-
/* XXX Need rt_init_rtg(), rt_clean_rtg() */
/**
@@ -834,21 +825,6 @@
BU_ASSERT(cpu_num >= 0);
BU_ASSERT(cpu_num < MAX_PSW);
- if (!RT_SEM_WORKER)
- RT_SEM_WORKER = bu_semaphore_register("RT_SEM_WORKER");
- if (!RT_SEM_RESULTS)
- RT_SEM_RESULTS = bu_semaphore_register("RT_SEM_RESULTS");
- if (!RT_SEM_MODEL)
- RT_SEM_MODEL = bu_semaphore_register("RT_SEM_MODEL");
- if (!RT_SEM_TREE0)
- RT_SEM_TREE0 = bu_semaphore_register("RT_SEM_TREE0");
- if (!RT_SEM_TREE1)
- RT_SEM_TREE1 = bu_semaphore_register("RT_SEM_TREE1");
- if (!RT_SEM_TREE2)
- RT_SEM_TREE2 = bu_semaphore_register("RT_SEM_TREE2");
- if (!RT_SEM_TREE3)
- RT_SEM_TREE3 = bu_semaphore_register("RT_SEM_TREE3");
-
if (rtip)
RT_CK_RTI(rtip);
Modified: brlcad/trunk/src/librt/primitives/brep/brep.cpp
===================================================================
--- brlcad/trunk/src/librt/primitives/brep/brep.cpp 2019-05-13 15:23:13 UTC
(rev 73053)
+++ brlcad/trunk/src/librt/primitives/brep/brep.cpp 2019-05-13 15:24:29 UTC
(rev 73054)
@@ -552,7 +552,7 @@
index = -1;
/* figure out which face to work on next */
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(BU_SEM_LISTS);
for (size_t i = 0; i < faceCount; i++) {
if (bbbp->faces[i] == NULL) {
index = i;
@@ -560,7 +560,7 @@
break;
}
}
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(BU_SEM_LISTS);
if (index != -1) {
/* bu_log("thread %d: preparing face %d of %d\n", cpu, index+1,
faceCount); */
Modified: brlcad/trunk/src/librt/tree.c
===================================================================
--- brlcad/trunk/src/librt/tree.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/librt/tree.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -420,9 +420,9 @@
/* Enter an exclusive critical section to protect nsolids.
* nsolids++ needs to be locked to a SINGLE thread
*/
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(RT_SEM_STATS);
stp->st_bit = rtip->nsolids++;
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(RT_SEM_STATS);
/*
* Fill in the last little bit of the structure in full parallel
Modified: brlcad/trunk/src/proc-db/pix2g.c
===================================================================
--- brlcad/trunk/src/proc-db/pix2g.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/proc-db/pix2g.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -37,6 +37,8 @@
/* workers acquire semaphore number 0 on smp machines */
+#define P2G_WORKER RT_SEM_LAST
+#define P2G_INIT_COUNT P2G_WORKER+1
#define MAXSIZE 256
int done=0;
int ncpu=1;
@@ -84,10 +86,10 @@
struct wmember scanlineList;
BU_LIST_INIT(&scanlineList.l);
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(P2G_WORKER);
i=nextAvailableRow;
nextAvailableRow++;
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(P2G_WORKER);
if (i >= height) {
break;
@@ -123,9 +125,9 @@
* of the regions will use it.
***
sprintf(solidName, "%dx%d.s", i+1, j+1);
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(P2G_WORKER);
mk_sph(db_fp, solidName, p1, objectSize/2.0);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(P2G_WORKER);
*/
/* make the region */
@@ -143,9 +145,9 @@
MAT_IDN(matrix);
MAT_DELTAS(matrix, p1[0], p1[1], 0.0);
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(P2G_WORKER);
mk_lcomb(db_fp, scratch, &wm_hd, is_region, NULL, NULL, rgb, 0);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(P2G_WORKER);
mk_addmember(scratch, &scanlineList.l, matrix, WMOP_UNION);
}
@@ -152,9 +154,9 @@
/* write out a combination for each scanline */
sprintf(scratch, "%d.c", i+1);
- bu_semaphore_acquire(BU_SEM_GENERAL);
+ bu_semaphore_acquire(P2G_WORKER);
mk_lcomb(db_fp, scratch, &scanlineList, 0, NULL, NULL, NULL, 0);
- bu_semaphore_release(BU_SEM_GENERAL);
+ bu_semaphore_release(P2G_WORKER);
/* all threads keep track of the scan line (in case they get to the end
first */
sprintf(scratch, "%d.c", i+1);
Modified: brlcad/trunk/src/rt/worker.c
===================================================================
--- brlcad/trunk/src/rt/worker.c 2019-05-13 15:23:13 UTC (rev 73053)
+++ brlcad/trunk/src/rt/worker.c 2019-05-13 15:24:29 UTC (rev 73054)
@@ -431,10 +431,10 @@
pixelTime = rt_get_timer(NULL,NULL); /* FIXME: needs to use
bu_gettime() */
/* bu_log("PixelTime = %lf X:%d Y:%d\n", pixelTime, a.a_x, a.a_y); */
- bu_semaphore_acquire(RT_SEM_RESULTS);
+ bu_semaphore_acquire(RT_SEM_LAST-2);
timeTable = timeTable_init(width, height);
timeTable_input(a.a_x, a.a_y, pixelTime, timeTable);
- bu_semaphore_release(RT_SEM_RESULTS);
+ bu_semaphore_release(RT_SEM_LAST-2);
}
/* we're done */
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits