示例#1
0
/* ========================================================================= */
int meminfo_update(int interval)
{
   struct pitem *this_pitem;
   int32_t *lastdptr;
   int32_t *thisdptr;

   if ( FillReadBuff(this_data->rbuf) )
      return(1);

   /* Move unstructured data to the parsed data struct */
   parse_proc_file();

   /* Walk the update item list - update items */
   this_pitem = this_provider->ui_list;
   while ( this_pitem )
   {
      thisdptr = (int32_t *)((unsigned long)this_data->thispd + (unsigned long)this_pitem->sioffset);
      lastdptr = (int32_t *)((unsigned long)this_data->lastpd + (unsigned long)this_pitem->sioffset);
      if(CalcData(this_pitem, lastdptr, thisdptr, interval))
         return(1);

      this_pitem = this_pitem->next_ui;
   }

   return(0);
}
示例#2
0
Parallelogram3d :: Parallelogram3d (Point<3> ap1, Point<3> ap2, Point<3> ap3)
{
  p1 = ap1;
  p2 = ap2;
  p3 = ap3;

  CalcData();
}
示例#3
0
void  Brick :: Transform (Transformation<3> & trans)
{
  trans.Transform (p1);
  trans.Transform (p2);
  trans.Transform (p3);
  trans.Transform (p4);

  CalcData();
}
示例#4
0
void Parallelogram3d :: SetPoints (Point<3> ap1, 
				   Point<3> ap2, 
				   Point<3> ap3)
{
  p1 = ap1;
  p2 = ap2;
  p3 = ap3;

  CalcData();
}
示例#5
0
Brick :: Brick (Point<3> ap1, Point<3> ap2, 
		Point<3> ap3, Point<3> ap4)
{
  faces.SetSize (6);
  surfaceids.SetSize (6);
  surfaceactive.SetSize(6);

  p1 = ap1; p2 = ap2;
  p3 = ap3; p4 = ap4;

  for (int i = 0; i < 6; i++)
    {
      faces[i] = new Plane (Point<3>(0,0,0), Vec<3> (0,0,1));
      surfaceactive[i] = 1;
    }

  CalcData();
}
示例#6
0
void Brick :: SetPrimitiveData (Array<double> & coeffs)
{
  p1(0) = coeffs.Elem(1);
  p1(1) = coeffs.Elem(2);
  p1(2) = coeffs.Elem(3);

  p2(0) = coeffs.Elem(4);
  p2(1) = coeffs.Elem(5);
  p2(2) = coeffs.Elem(6);

  p3(0) = coeffs.Elem(7);
  p3(1) = coeffs.Elem(8);
  p3(2) = coeffs.Elem(9);

  p4(0) = coeffs.Elem(10);
  p4(1) = coeffs.Elem(11);
  p4(2) = coeffs.Elem(12);

  CalcData();
}
示例#7
0
文件: procstat.c 项目: bochf/testing
/* ========================================================================= */
int procstat_update(int interval)
{
   struct cpudata *cpudtemp;
   struct pitem *this_pitem;
   struct cpu_data_bin *this_bin;
   uint64_t total;  /* Total (used for pct */
   uint64_t tthis;  /* Temp this */
   uint64_t tlast;  /* Temp last */
   uint64_t *tptr;  /* Temp pointer */

   /* NOTE: Because we use a "data bin" we don't care if this is a per-CPU
            stat or the total stat. In either case the updates happen 
            against the "full" view, and the per-item is provided by the
            "data bin" where individual calculations are done. */

   /* First, update stats from /proc/stat */
   if(update_stat_data(this_buf, this_data)) /* <---- This rotates the main set of data */
      return(1);

   /* Next, walk the update list and update items */
   this_pitem = this_provider->ui_list;
   while ( this_pitem )
   {
      /* Get a "local" reference to the data. */
      this_bin = (struct cpu_data_bin *)this_pitem->dstruct;

      /* Ok.... Because we use the "data bin" as a view, and not an
         actual container in the main struct. (More on *why* later.)
         The data gets rotated in the main struct, but the view never
         got updated (rotated). So the data needs to be rotated in 
         the view too. The view is required for EACH pitem because
         there can be multiple pitems for a single CPU - or even for
         a single stat on a CPU (RAW and PCT). The view holds this
         info, so there must be an individual for each pitem. Also
         note that the "main view" is rotated above in the
         update_stat_data() function. This rotation keeps them in
         sync. */
      cpudtemp = this_bin->lastd;
      this_bin->lastd = this_bin->thisd;
      this_bin->thisd = cpudtemp;


      if ( DTYPE_PCT == this_bin->dtype )
      {
         /* Save the total value. Likely it will be calculated over and over.
            This saves some of that ugly calculation at the cost of a simple
            compare. */

         if ( 0 == this_bin->lastd->total ) /* First run problem (should only happen once) */
         {
            this_bin->lastd->total = this_bin->lastd->user   +
                                     this_bin->lastd->nice   +
                                     this_bin->lastd->sys    +
                                     this_bin->lastd->idle   +
                                     this_bin->lastd->iowait +
                                     this_bin->lastd->irq    +
                                     this_bin->lastd->sirq   +
                                     this_bin->lastd->steal  +
                                     this_bin->lastd->guest  +
                                     this_bin->lastd->gnice;


         }

         if ( 0 == this_bin->thisd->total )
         {
            this_bin->thisd->total = this_bin->thisd->user   +
                                     this_bin->thisd->nice   +
                                     this_bin->thisd->sys    +
                                     this_bin->thisd->idle   +
                                     this_bin->thisd->iowait +
                                     this_bin->thisd->irq    +
                                     this_bin->thisd->sirq   +
                                     this_bin->thisd->steal  +
                                     this_bin->thisd->guest  +
                                     this_bin->thisd->gnice;
         }


         total = this_bin->thisd->total - this_bin->lastd->total;

         /* This was the old way - calculating total each time - in its entirety
         total = (this_bin->thisd->user   - this_bin->lastd->user) +
                 (this_bin->thisd->nice   - this_bin->lastd->nice) +
                 (this_bin->thisd->sys    - this_bin->lastd->sys) +
                 (this_bin->thisd->idle   - this_bin->lastd->idle) +
                 (this_bin->thisd->iowait - this_bin->lastd->iowait) +
                 (this_bin->thisd->irq    - this_bin->lastd->irq) +
                 (this_bin->thisd->sirq   - this_bin->lastd->sirq) +
                 (this_bin->thisd->steal  - this_bin->lastd->steal) +
                 (this_bin->thisd->guest  - this_bin->lastd->guest) +
                 (this_bin->thisd->gnice  - this_bin->lastd->gnice);
         */

         /* ISSUE: This works, but could likely be simplified */
         tptr = (uint64_t *)((unsigned long)this_bin->thisd + (unsigned long)this_pitem->sioffset);
         tthis = *tptr;
         tptr = (uint64_t *)((unsigned long)this_bin->lastd + (unsigned long)this_pitem->sioffset);
         tlast = *tptr;

         if ( total > 0 )
            total = ((tthis - tlast) * 100) / total; /* re-using total here */
         else
            total = 0; /* incase it somehow went negative */

         *((int16_t *)this_pitem->data_ptr) = (int16_t)total;
      }


      if ( DTYPE_RAW == this_bin->dtype )
      {

         CalcData(this_pitem,
                  (uint64_t *)((unsigned long)this_bin->lastd + (unsigned long)this_pitem->sioffset),
                  (uint64_t *)((unsigned long)this_bin->thisd + (unsigned long)this_pitem->sioffset),
                  interval);
      }

      this_pitem = this_pitem->next_ui;
   }

   return(0);
}