Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  free_timer.c

  Sprache: C
 

// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) 2025. Huawei Technologies Co., Ltd */
#include <linux/bpf.h>
#include <time.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_helpers.h>

#define MAX_ENTRIES 8

struct map_value {
 struct bpf_timer timer;
};

struct {
 __uint(type, BPF_MAP_TYPE_HASH);
 __type(key, int);
 __type(value, struct map_value);
 __uint(max_entries, MAX_ENTRIES);
} map SEC(".maps");

static int timer_cb(void *map, void *key, struct map_value *value)
{
 volatile int sum = 0;
 int i;

 bpf_for(i, 01024 * 1024) sum += i;

 return 0;
}

static int start_cb(int key)
{
 struct map_value *value;

 value = bpf_map_lookup_elem(&map, (void *)&key);
 if (!value)
  return 0;

 bpf_timer_init(&value->timer, &map, CLOCK_MONOTONIC);
 bpf_timer_set_callback(&value->timer, timer_cb);
 /* Hope 100us will be enough to wake-up and run the overwrite thread */
 bpf_timer_start(&value->timer, 100000, BPF_F_TIMER_CPU_PIN);

 return 0;
}

static int overwrite_cb(int key)
{
 struct map_value zero = {};

 /* Free the timer which may run on other CPU */
 bpf_map_update_elem(&map, (void *)&key, &zero, BPF_ANY);

 return 0;
}

SEC("syscall")
int BPF_PROG(start_timer)
{
 bpf_loop(MAX_ENTRIES, start_cb, NULL, 0);
 return 0;
}

SEC("syscall")
int BPF_PROG(overwrite_timer)
{
 bpf_loop(MAX_ENTRIES, overwrite_cb, NULL, 0);
 return 0;
}

char _license[] SEC("license") = "GPL";

Messung V0.5 in Prozent
C=96 H=89 G=92

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-06-07) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=655579