Andrés Terrasa
posix_trace_attr_getname(&trace_attr, str); + fprintf(stderr, "get name (%d): %s\n", error, str); + + error = posix_trace_attr_getcreatetime(&trace_attr, &time); + fprintf(stderr, "get create time (%d): %ld.%ld\n", error, + time.tv_sec, time.tv_nsec); + + error = posix_trace_attr_getclockres(&trace_attr, &time); + fprintf(stderr, "get clock res (%d): %ld.%ld\n", error, + time.tv_sec, time.tv_nsec); + + error = posix_trace_attr_getstreamfullpolicy(&trace_attr, &pol); + fprintf(stderr, "get full policy (%d): %d\n", error, pol); + + error = posix_trace_attr_getmaxusereventsize(&trace_attr, 0, &size); + fprintf(stderr, "get max user event size (%d): %d\n", error, size); + + error = posix_trace_attr_getmaxsystemeventsize(&trace_attr, &size); + fprintf(stderr, "get max system event size (%d): %d\n", error, size); + + error = posix_trace_attr_getmaxdatasize(&trace_attr, &size); + fprintf(stderr, "get max data size (%d): %d\n", error, size); + + error = posix_trace_attr_getstreamsize(&trace_attr, &size); + fprintf(stderr, "get stream size (%d): %d\n", error, size); + + + // Print the full list of event types available in the stream: + + error = posix_trace_eventtypelist_rewind(trace_id); + fprintf(stderr, "event list rewind (%d)\n", error); + + error = posix_trace_eventtypelist_getnext_id (trace_id, &ev, &unavailable); + while( ! unavailable && ! error) { + + error = posix_trace_eventid_get_name (trace_id, ev, str); + + if (! error) { + fprintf(stderr, "event getname (%d): %s\n", error, str); + } + // Get the next one: + error = posix_trace_eventtypelist_getnext_id (trace_id, &ev, + &unavailable); + } + + + // Print the current status of the stream : + error = posix_trace_get_status(trace_id, &status); + fprintf(stderr, "event get status (%d): %d %d %d \n", error, + status.posix_stream_status, status.posix_stream_full_status, + status.posix_stream_overrun_status); + + + + + // Start retrieving events while the stream is open: + fprintf(stderr, "\n\nNow retrieving events: \n"); + + + while(1) { + + error = posix_trace_getnext_event(trace_id, &event, &data, sizeof(data), + &data_len, &unavailable); + + if(error) { + fprintf(stderr,"No more events (%d). Exiting\n", error); + exit(0); + + } else if (unavailable) { + fprintf(stderr, " Event unavailable\n"); + + } else { + + fprintf(stderr, " ** New event ----------\n"); + fprintf(stderr, " Event identifier = %d\n", event.posix_event_id); + fprintf(stderr, " Process ID = %d\n", event.posix_pid); + fprintf(stderr, " Address = %x\n", (int) event.posix_prog_address); + fprintf(stderr, " Truncation status= %d\n", event.posix_truncation_status); + fprintf(stderr, " Timestamp = %ld.%9ld\n", event.posix_timestamp.tv_sec, event.posix_timestamp.tv_nsec); + fprintf(stderr, " Thread ID = %d\n", (int) event.posix_thread_id); + + posix_trace_eventid_get_name (trace_id, event.posix_event_id, str); + fprintf(stderr, " Event Name = %s\n", str); + + // Now switch depending on the event type (name): + if (!strcmp(str,"user event char")) { + c = (char *) data; + fprintf(stderr, " Data (char) = %c\n", *c); + } + + else if (!strcmp(str,"user event int")) { + i = (int *) data; + fprintf(stderr, " Data (int) = %d\n", *i); + } + + else if (!strcmp(str,"user event string")) { + fprintf(stderr, " Data (string) = %s\n", (char *) data); + + } + + else if (!strcmp(str,"user event linux")) { + i = (int *) data; + fprintf(stderr, " Data (int) = %d\n", *i); + } + + else { + fprintf(stderr, " Data unknown\n" ); + } + + fprintf(stderr, " Data length = %d\n", data_len); + fprintf(stderr, " ----------\n\n"); + } + + } + + return 0; + + +} diff -NurBb rtlinux-3.1-orig/examples/posixtrace/rtl-and-linux/linux_target.c rtlinux-3.1-posixtrace/examples/posixtrace/rtl-and-linux/linux_target.c --- rtlinux-3.1-orig/examples/posixtrace/rtl-and-linux/linux_target.c 1970-01-01 01:00:00.000000000 +0100 +++ rtlinux-3.1-posixtrace/examples/posixtrace/rtl-and-linux/linux_target.c 2002-09-10 17:46:43.000000000 +0200 @@ -0,0 +1,100 @@ +/* + FILE: + linux_target.c + + DESCRIPTION: + Linux side of a sample application using the POSIX trace + support. This Linux program also traces events into the + active stream(s) that the RT-Linux side has created. + + See README file for details. + + Copyright (C) 2001 + Ana Garcia Fornes + Andres Terrasa Barrena + Ignacio Paches Giner + Agustin Espinosa Minguet + + This is free software; you can redistribute it and/or modify it under + terms of the GNU General Public License as published by the Free Soft- + ware Foundation; either version 2, or (at your option) any later ver- + sion. It is distributed in the hope that it will be useful, but WITH- + OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. You should have received a copy of the GNU General + Public License; see file COPYING. If not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + LAST REVISION: + September 2001 + +*/ + +#include +#include +#include + +#include + + + +//#define DEBUG + + + +#define NTIMES 30 + + +void timer_handler(int dummy) { + return; +} + + +int main(void) { + + int ntimes; + trace_event_id_t ev_linux; + trace_event_id_t ev_string; + void *data; + char s[32] = "Linux says: Hello world!"; + struct itimerval timeout; + struct sigaction action; + + // Create a new type of event: + posix_trace_eventid_open ("user event linux", &ev_linux); + + // Register an event type which has been created in RT-Linux + posix_trace_eventid_open ("user event string", &ev_string); + + + // Initialize the timeout value (oneshot, 500 ms): + timeout.it_interval.tv_sec = 0; + timeout.it_interval.tv_usec = 0; + timeout.it_value.tv_sec = 0; + timeout.it_value.tv_usec = 500000; + + sigfillset(&(action.sa_mask)); + sigdelset(&(action.sa_mask), SIGALRM); + action.sa_handler = timer_handler; + sigaction(SIGALRM,&action,NULL); + + + // Enter the main loop: trace this event and sleep for a timeout: + for (ntimes = 0; ntimes < NTIMES; ntimes ++) { + +#ifdef DEBUG + fprintf(stderr, "linux_target: Tracing value %d\n", ntimes); +#endif + + data = (void *) & ntimes; + posix_trace_event(ev_linux, data, sizeof(int)); + + posix_trace_event(ev_string, s, sizeof(s)); + + setitimer(ITIMER_REAL,&timeout,NULL); + pause(); + } + + return 0; + +} diff -NurBb rtlinux-3.1-orig/examples/posixtrace/rtl-and-linux/rtl_tasks.c rtlinux-3.1-posixtrace/examples/posixtrace/rtl-and-linux/rtl_tasks.c --- rtlinux-3.1-orig/examples/posixtrace/rtl-and-linux/rtl_tasks.c 1970-01-01 01:00:00.000000000 +0100 +++ rtlinux-3.1-posixtrace/examples/posixtrace/rtl-and-linux/rtl_tasks.c 2002-09-18 17:37:59.000000000 +0200 @@ -0,0 +1,208 @@ +/* + FILE: + rtl_tasks.c + + DESCRIPTION: + RT-Linux side of a sample application using the POSIX trace + support. + + See README file for details. + + Copyright (C) 2001 + Ana Garcia Fornes + Andres Terrasa Barrena + Ignacio Paches Giner + Agustin Espinosa Minguet + + This is free software; you can redistribute it and/or modify it under + terms of the GNU General Public License as published by the Free Soft- + ware Foundation; either version 2, or (at your option) any later ver- + sion. It is distributed in the hope that it will be useful, but WITH- + OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. You should have received a copy of the GNU General + Public License; see file COPYING. If not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + LAST REVISION: + September 2001 + +*/ + +#include +#include +#include +#include +#include +#include + + +static trace_id_t trid; +static trace_event_id_t ev_char, ev_int, ev_string; +static pthread_t thr1, thr2, thr3, thr4; + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + + + +void *writer(void *dummy) { + int i; + int j; + char s[32] = "RT-Linux says: Hello world!"; + char c; + int k; + void *data; + + // Create some new event types: + posix_trace_eventid_open ("user event string", &ev_string); + posix_trace_eventid_open ("user event char", &ev_char); + posix_trace_eventid_open ("user event int", &ev_int); + + // Initialize data to be recorded along with the events + c = \'A\'; + k = 0; + + + for (i=0; i<50; i++) { + + pthread_mutex_lock(&mutex); + + // Trace the "user event char" event and consume some CPU: + data = (void *) & c; + posix_trace_event(ev_char, data, sizeof(char)); + c += 1; + for (j=0; j<40000; j++) ; + + // Trace the "user event int" event and consume some CPU: + data = (void *) & k; + posix_trace_event(ev_int, data, sizeof(int)); + k += 1; + for (j=0; j<40000; j++) ; + + // Trace the "user event string" event and consume some CPU: + posix_trace_event(ev_string, s, sizeof(s)); + for (j=0; j<40000; j++) ; + + pthread_mutex_unlock(&mutex); + + // Consume some more CPU and go to sleep until next period: + for (j=0; j<40000; j++) ; + pthread_wait_np(); + } + return (void *) 0; +} + + + + + +void *just_execute(void *loops) { + int i; + int j; + int nloops; + + nloops = (int) loops; + + for (i=0; i<100; i++) { + + pthread_wait_np(); + + for (j=0; j +#else +#include +#endif + + +#include "trace_options.h" // Which options are currently supported + + + + +/* + NOTE: + This header file is mostly ordered and labelled according to the + POSIX "P1003.1q: Tracing" standard document. +*/ + + +/* + 2.8.2. Minimum values +*/ +#define _POSIX_TRACE_SYS_MAX 8 +#define _POSIX_TRACE_USER_EVENT_MAX 32 +#define _POSIX_TRACE_NAME_MAX 64 +#define _POSIX_TRACE_EVENT_NAME_MAX 30 + + + + +/* + 24.2. Data definitions +*/ + +// 24.2.1.2. posix_trace_event_info needs this: +typedef int _trace_event_id_t; + + +// 24.2.2 Trace stream attributes +typedef struct { + int magic; // Magic number + + char
关注
立即认领
分享
关注
立即认领
分享
基本信息
浏览量:17
职业迁徙
个人简介
暂无内容
研究兴趣
论文共 46 篇作者统计合作学者相似作者
按年份排序按引用量排序主题筛选期刊级别筛选合作者筛选合作机构筛选
时间
引用量
主题
期刊级别
合作者
合作机构
Revista de la Facultad de Derecho de Méxicono. 285 (2023): 257-274
引用0浏览0引用
0
0
ELECTRONICSno. 3 (2023): 659-659
Sergio Márquez-Sánchez,Sara Rodríguez González, Sergio Alonso Rollán, David Pérez-López,Andrés Terrasa,Fernando De la Prieta
Communications in computer and information sciencepp.41-52, (2023)
引用0浏览0引用
0
0
International Conference on Practical Applications of Agents and Multi-Agent Systems (PAAMS)pp.320-331, (2022)
加载更多
作者统计
合作学者
合作机构
D-Core
- 合作者
- 学生
- 导师
数据免责声明
页面数据均来自互联网公开来源、合作出版商和通过AI技术自动分析结果,我们不对页面数据的有效性、准确性、正确性、可靠性、完整性和及时性做出任何承诺和保证。若有疑问,可以通过电子邮件方式联系我们:report@aminer.cn