 get device activation/deactivation
notifications.  But both client and daemon will avoid all the marshalling and
unmarshalling overhead.

PERMISSIONS
   This file is Copyright 2010 by the GPSD project
   SPDX-License-Identifier: BSD-2-clause

***************************************************************************/

#include "gpsd_config.h"

#ifdef SHM_EXPORT_ENABLE

#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/time.h>

#include "gpsd.h"
#include "libgps.h" /* for SHM_PSEUDO_FD */


bool shm_acquire(struct gps_context_t *context)
/* initialize the shared-memory segment to be used for export */
{
    long shmkey = getenv("GPSD_SHM_KEY")? \
                      strtol(getenv("GPSD_SHM_KEY"), NULL, 0) : GPSD_SHM_KEY;

    int shmid = shmget((key_t)shmkey, sizeof(struct shmexport_t),
                       (int)(IPC_CREAT|0666));
    if (shmid == -1) {
        GPSD_LOG(LOG_ERROR, &context->errout,
                 "shmget(0x%lx, %zd, 0666) for SHM export failed: %s\n",
                 shmkey,
                 sizeof(struct shmexport_t),
                 strerror(errno));
        return false;
    } else
        GPSD_LOG(LOG_PROG, &context->errout,
                 "shmget(0x%lx, %zd, 0666) for SHM export succeeded\n",
                 shmkey,
                 sizeof(struct shmexport_t));

    context->shmexport = (void *)shmat(shmid, 0, 0);
    if ((int)(long)context->shmexport == -1) {
        GPSD_LOG(LOG_ERROR, &context->errout,
                 "shmat failed: %s\n", strerror(errno));
        context->shmexport = NULL;
        return false;
    }
    context->shmid = shmid;

    GPSD_LOG(LOG_PROG, &context->errout,
             "shmat() for SHM export succeeded, segment %d\n", shmid);
    return true;
}

/* release the shared-memory segment used for export */
void shm_release(struct gps_context_t *context)
{
    if (context->shmexport == NULL)
        return;

    /* Mark shmid to go away when no longer used
     * Having it linger forever is bad, and when the size enlarges
     * it can no longer be opened
     */
    if (shmctl(context->shmid, IPC_RMID, NULL) == -1) {
        GPSD_LOG(LOG_WARN, &context->errout,
                 "shmctl for IPC_RMID failed, errno = %d (%s)\n",
                 errno, strerror(errno));
    }
    (void)shmdt((const void *)context->shmexport);
}

/* export an update to all listeners */
void shm_update(struct gps_context_t *context, struct gps_data_t *gpsdata)
{
    if (context->shmexport!= NULL)
    {
        static int tick;
        volatile struct shmexport_t *shared = \
                            (struct shmexport_t *)context->shmexport;

        ++tick;
        /*
         * Following block of instructions must not be reordered, otherwise
         * havoc will ensue.
         *
         * This is a simple optimistic-concurrency technique.  We write
         * the second bookend first, then the data, then the first bookend.
         * Reader copies what it sees in normal order; that way, if we
         * start to write the segment during the read, the second bookend will
         * get clobbered first and the data can be detected as bad.
         *
         * Of course many architectures, like Intel, make no guarantees
         * about the actual memory read or write order into RAM, so this
         * is partly wishful thinking.  Thus the need for the memory_barriers()
         * to enforce the required order.
         */
        shared->bookend2 = tick;
        memory_barrier();
        shared->gpsdata = *gpsdata;
        memory_barrier();
#ifndef USE_QT
        shared->gpsdata.gps_fd = SHM_PSEUDO_FD;
#else
        shared->gpsdata.gps_fd = (void *)(intptr_t)SHM_PSEUDO_FD;
#endif /* USE_QT */
        memory_barrier();
        shared->bookend1 = tick;
    }
}


#endif /* SHM_EXPORT_ENABLE */

/* end */
// vim: set expandtab shiftwidth=4
Home > Blog > Oh Deer!
Fall in The Parklands is a wonderful time to enjoy the crisp cool air and view the Eastern Deciduous Forest with its many colors. As the days grow shorter animals begin their preparations for the colder months ahead. The shortened period of daylight is the stimulus for several biologic changes such as the shedding of leaves, the southward migration of many bird species, and the beginning of the breading season, also called the fall rut, for white-tailed deer. White-tailed deer exhibit an interesting assortment of behaviors associated with their breeding season. In Kentucky the breeding season typically runs from October to mid-January, peaking in November. Most fawns are born in June after a seven month gestation. Fall is a great time for observing deer in natural areas such as The Parklands, but it is also a time to exercise caution when driving on park roads.
Deer begin the breeding season by establishing a hierarchy of dominance. Young males spar with one another to establish dominance and attempt to overturn the ruling dominant male. These sparring events usually involve pushing and shoving but may eventually escalate to more serious fights between males of equal status and strength. The decrease in daylight stimulates male deer to produce more testosterone and shed the velvet from their antlers. Deer rub their antlers on scrubs or small trees during the cool fall nights. These markings can be seen on many trees throughout The Parklands, and are used as scent signposts for other deer in the area. You may even see areas called “scrapes” made by bucks pawing at the ground exposing bare soil and urinating to mark their territory. These “scrapes” are usually accompanied by a broken branch that may also be scent marked. Hikers should keep an eye out on the trails for evidence of deer “rubbings” and “scrapes”. With few natural predators and a steady food supply, deer are very abundant in The Parklands and motorists should expect to see them often along park roads as well as the surrounding county roads.
The true breeding season begins when the female deer, which are called does, enter estrus and become receptive to males. This is really the most dangerous time for deer and motorists. The male deer begin to exhibit chasing behavior and do not stop to look both ways before crossing. Deer are most active in the early morning and again in the evenings between five and eight. According to the Kentucky State police 47% of all collisions with deer occur between October and December, accounting for 1.6 million deer- vehicle collisions yearly. So while you may have a natural fear of snakes or coyotes, in Kentucky you are much more likely to be injured in a vehicle-deer accident than in an encounter with any other wild animal. So while you are out enjoying this beautiful autumn air keep an extra eye open for deer along roadsides in the park.
About noon yesterday, during the storm which passed over this section, the new house recently erected on the Dysert Place, one half mile south of Walnut Grove, in which Simpson Jones lived, was struck about noon and Mr. Jones, who was lying on the floor in a lower room near the end of the house which was struck, was instantly killed.
His wife was rendered uncounscious for some time, but has recovered save from the terrible effects of the shock. The house was badly damaged, the entire end being practically torn out. Mr. Jones' death is a sad blow to the family, as they recently came to this state from Ohio.
The funeral services of Mrs. Mary Hedrick were held at this place Sunday afternoon conducted by the Revs. Wilmer and Patterson, after which intermount took place in the Carbondale Cemetery. The husband and their three little boys have the sympathy of the entire community.
Information in this record is provided for personal research purposes only
and may not