blink.loglog.txt是什么文件件

flash.blink - 必应 词典网络瞬闪;闪身飞逝1.瞬闪...铠”回复自我。第九卷中,作为第6代Chrome Disaster时,可以使用历代Chrome Disaster的技能,例如初代(Chrom.Falcon)的瞬闪(F…|2.闪身飞逝...er的技能,例如初代(Chrom.Falcon)的闪身飞逝(Flash.Blink)、二代(Magnesium Drake)的炎之吐息(Flame.Breeze)、五代(…|例句释义:全部,瞬闪,闪身飞逝类别:全部,口语,书面语,标题,技术来源:全部,字典,网络难度:全部,简单,中等,难更多例句筛选收起例句筛选1. this
happening,
doesn't flash, , ,
stall必应词典应用准确权威无广告下 载 手 机 版 必 应 词 典体 验 P C 版 必 应 词 典Android Log Tag含义
来源:博客园
在分析Android问题的时候重要的手段之一就是分析log,在events.log中有很多系统log,其中有些log的含义并不是很了解,下面就是从安卓源码中得到的系统log的tag。 关于Tag的说明如下:以 “30005 am_create_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5)” 为例, 其中: 30005 :相当于是am_create_activity这个tag的索引或者标识。不会出现在events.txt中。 am_create_activity:TAG名字 后面用()括起来的相当于是这个log的一些信息,以(User|1|5)为例,User表示信息名字,User表示UID,1表示在打印出的log中该信息的数据类型,5表示该数据的单位。 数据类型有: 1:int 2:long 3:string 4:list 5:float 数据的单位有: 1:Number of objects 2:Number of bytes 3:Number of milliseconds 4:Number of allocations 5:Id 6:Percent 所以(User|1|5)表示的意思是:这项信息表示的是User,在Linux即相当于UID,信息的数据类型为1,即int,数据的单位为5,即Id。其他的类似。 一个实际的log如下: 10-31 17:53:38.288
I am_create_activity: [0,,pany.photoeditor/com.android.gallery3d.filtershow.FilterShowActivity,android.intent.action.EDIT,image/*,content://media/external/images/media/4427,1],表示的含义即为: 这是一个表示activity创建的log 程序的UID为0 要创建的该activity的TOKEN为 该动作所处的Task ID为127 所要创建的activity组件名为 cn.company.photoeditor/com.android.gallery3d.filtershow.FilterShowActivity 创建该activity消息中的action为android.intent.action.EDIT,MIME TYPE为image/*,URI为content://media/external/images/media/4427,附带的flag为1 下面是源码的中tag定义文件: service/core/java/com/android/server/am/EventLogTags.logtags: # See system/core/logcat/event.logtags for a description of the format of this file.option java_package com.android.server.am2719 configuration_changed (config mask|1|5)2721 cpu (total|1|6),(user|1|6),(system|1|6),(iowait|1|6),(irq|1|6),(softirq|1|6)# ActivityManagerService.systemReady() starts:3040 boot_progress_ams_ready (time|2|3)# ActivityManagerService calls enableScreenAfterBoot():3050 boot_progress_enable_screen (time|2|3)# Do not change these names without updating the checkin_events setting in# google3/googledata/wireless/android/provisioning/gservices.config !!## An activity is being finished:30001 am_finish_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3)# A task is being brought to the front of the screen:30002 am_task_to_front (User|1|5),(Task|1|5)# An existing activity is being given a new intent:30003 am_new_intent (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5)# A new task is being created:30004 am_create_task (User|1|5),(Task ID|1|5)# A new activity is being created in an existing task:30005 am_create_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5)# An activity has been resumed into the foreground but was not already running:30006 am_restart_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3)# An activity has been resumed and is now in the foreground:30007 am_resume_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3)# Application Not Responding30008 am_anr (User|1|5),(pid|1|5),(Package Name|3),(Flags|1|5),(reason|3)# Activity launch time30009 am_activity_launch_time (User|1|5),(Token|1|5),(Component Name|3),(time|2|3)# Application process bound to work30010 am_proc_bound (User|1|5),(PID|1|5),(Process Name|3)# Application process died30011 am_proc_died (User|1|5),(PID|1|5),(Process Name|3)# The Activity Manager failed to pause the given activity.30012 am_failed_to_pause (User|1|5),(Token|1|5),(Wanting to pause|3),(Currently pausing|3)# Attempting to pause the current activity30013 am_pause_activity (User|1|5),(Token|1|5),(Component Name|3)# Application process has been started30014 am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3)# An application process has been marked as bad30015 am_proc_bad (User|1|5),(UID|1|5),(Process Name|3)# An application process that was bad is now marked as good30016 am_proc_good (User|1|5),(UID|1|5),(Process Name|3)# Reporting to applications that memory is low30017 am_low_memory (Num Processes|1|1)# An activity is being destroyed:30018 am_destroy_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3)# An activity has been relaunched, resumed, and is now in the foreground:30019 am_relaunch_resume_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3)# An activity has been relaunched:30020 am_relaunch_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3)# The activity's onPause has been called.30021 am_on_paused_called (User|1|5),(Component Name|3),(Reason|3)# The activity's onResume has been called.30022 am_on_resume_called (User|1|5),(Component Name|3),(Reason|3)# Kill a process to reclaim memory.30023 am_kill (User|1|5),(PID|1|5),(Process Name|3),(OomAdj|1|5),(Reason|3)# Discard an undelivered serialized broadcast (timeout/ANR/crash)30024 am_broadcast_discard_filter (User|1|5),(Broadcast|1|5),(Action|3),(Receiver Number|1|1),(BroadcastFilter|1|5)30025 am_broadcast_discard_app (User|1|5),(Broadcast|1|5),(Action|3),(Receiver Number|1|1),(App|3)# A service is being created30030 am_create_service (User|1|5),(Service Record|1|5),(Name|3),(UID|1|5),(PID|1|5)# A service is being destroyed30031 am_destroy_service (User|1|5),(Service Record|1|5),(PID|1|5)# A process has crashed too many times, it is being cleared30032 am_process_crashed_too_much (User|1|5),(Name|3),(PID|1|5)# An unknown process is trying to attach to the activity manager30033 am_drop_process (PID|1|5)# A service has crashed too many times, it is being stopped30034 am_service_crashed_too_much (User|1|5),(Crash Count|1|1),(Component Name|3),(PID|1|5)# A service is going to be restarted after its process went away30035 am_schedule_service_restart (User|1|5),(Component Name|3),(Time|2|3)# A client was waiting for a content provider, but its process was lost30036 am_provider_lost_process (User|1|5),(Package Name|3),(UID|1|5),(Name|3)# The activity manager gave up on a new process taking too long to start30037 am_process_start_timeout (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3)# Unhandled exception30039 am_crash (User|1|5),(PID|1|5),(Process Name|3),(Flags|1|5),(Exception|3),(Message|3),(File|3),(Line|1|5)# Log.wtf() called30040 am_wtf (User|1|5),(PID|1|5),(Process Name|3),(Flags|1|5),(Tag|3),(Message|3)# User switched30041 am_switch_user (id|1|5)# Activity fully drawn time30042 am_activity_fully_drawn_time (User|1|5),(Token|1|5),(Component Name|3),(time|2|3)# Activity focused30043 am_focused_activity (User|1|5),(Component Name|3),(Reason|3)# Stack focus30044 am_focused_stack (User|1|5),(Focused Stack Id|1|5),(Last Focused Stack Id|1|5),(Reason|3)# Running pre boot receiver30045 am_pre_boot (User|1|5),(Package|3)# Report collection of global memory state30046 am_meminfo (Cached|2|2),(Free|2|2),(Zram|2|2),(Kernel|2|2),(Native|2|2)# Report collection of memory used by a process30047 am_pss (Pid|1|5),(UID|1|5),(Process Name|3),(Pss|2|2),(Uss|2|2),(SwapPss|2|2)# Attempting to stop an activity30048 am_stop_activity (User|1|5),(Token|1|5),(Component Name|3)# The activity's onStop has been called.30049 am_on_stop_called (User|1|5),(Component Name|3),(Reason|3)# Report changing memory conditions (Values are ProcessStats.ADJ_MEM_FACTOR* constants)30050 am_mem_factor (Current|1|5),(Previous|1|5) services/core/java/com/android/server/EventLogTags.logtags: # See system/core/logcat/event.logtags for a description of the format of this file.option java_package com.android.server# ---------------------------# BatteryService.java# ---------------------------2722 battery_level (level|1|6),(voltage|1|1),(temperature|1|1)2723 battery_status (status|1|5),(health|1|5),(present|1|5),(plugged|1|5),(technology|3)# This is logged when battery goes from discharging to charging.# It lets us count the total amount of time between charges and the discharge level2730 battery_discharge (duration|2|3),(minLevel|1|6),(maxLevel|1|6)# ---------------------------# PowerManagerService.java# ---------------------------# This is logged when the device is being forced to sleep (typically by# the user pressing the power button).2724 power_sleep_requested (wakeLocksCleared|1|1)# This is logged when the screen on broadcast has completed2725 power_screen_broadcast_send (wakelockCount|1|1)# This is logged when the screen broadcast has completed2726 power_screen_broadcast_done (on|1|5),(broadcastDuration|2|3),(wakelockCount|1|1)# This is logged when the screen on broadcast has completed2727 power_screen_broadcast_stop (which|1|5),(wakelockCount|1|1)# This is logged when the screen is turned on or off.2728 power_screen_state (offOrOn|1|5),(becauseOfUser|1|5),(totalTouchDownTime|2|3),(touchCycles|1|1)# This is logged when the partial wake lock (keeping the device awake# regardless of whether the screen is off) is acquired or released.2729 power_partial_wake_state (releasedorAcquired|1|5),(tag|3)# The device is being asked to go into a soft sleep (typically by the ungaze gesture).# It logs the time remaining before the device would've normally gone to sleep without the request.2731 power_soft_sleep_requested (savedwaketimems|2)## Leave IDs through 2739 for more power logs (2730 used by battery_discharge above)## ---------------------------# DeviceStorageMonitorService.java# ---------------------------# The disk space free on the /data partition, in bytes2744 free_storage_changed (data|2|2)# Device low memory notification and disk space free on the /data partition, in bytes at that time2745 low_storage (data|2|2)# disk space free on the /data, /system, and /cache partitions in bytes2746 free_storage_left (data|2|2),(system|2|2),(cache|2|2)# file on cache partition was deleted2748 cache_file_deleted (path|3)# ---------------------------# NotificationManagerService.java# ---------------------------# when a NotificationManager.notify is called. status: 0=post, 1=update, 2=ignored2750 notification_enqueue (uid|1|5),(pid|1|5),(pkg|3),(id|1|5),(tag|3),(userid|1|5),(notification|3),(status|1)# when someone tries to cancel a notification, the notification manager sometimes# calls this with flags too2751 notification_cancel (uid|1|5),(pid|1|5),(pkg|3),(id|1|5),(tag|3),(userid|1|5),(required_flags|1),(forbidden_flags|1),(reason|1|5),(listener|3)# when someone tries to cancel all of the notifications for a particular package2752 notification_cancel_all (uid|1|5),(pid|1|5),(pkg|3),(userid|1|5),(required_flags|1),(forbidden_flags|1),(reason|1|5),(listener|3)# when the notification panel is shown# Note: New tag range starts here since 2753+ have been used below.27500 notification_panel_revealed (items|1)# when the notification panel is hidden27501 notification_panel_hidden# when notifications are newly displayed on screen, or disappear from screen27510 notification_visibility_changed (newlyVisibleKeys|3),(noLongerVisibleKeys|3)# when notifications are expanded, or contracted27511 notification_expansion (key|3),(user_action|1),(expanded|1),(lifespan|1),(freshness|1),(exposure|1)# when a notification has been clicked27520 notification_clicked (key|3),(lifespan|1),(freshness|1),(exposure|1)# when a notification action button has been clicked27521 notification_action_clicked (key|3),(action_index|1),(lifespan|1),(freshness|1),(exposure|1)# when a notification has been canceled27530 notification_canceled (key|3),(reason|1),(lifespan|1),(freshness|1),(exposure|1)# replaces 27510 with a row per notification27531 notification_visibility (key|3),(visibile|1),(lifespan|1),(freshness|1),(exposure|1),(rank|1)# a notification emited noise, vibration, or light27532 notification_alert (key|3),(buzz|1),(beep|1),(blink|1)# a notification was added to a autogroup27533 notification_autogrouped (key|3)# notification was removed from an autogroup275534 notification_unautogrouped (key|3)# ---------------------------# Watchdog.java# ---------------------------2802 watchdog (Service|3)2803 watchdog_proc_pss (Process|3),(Pid|1|5),(Pss|1|2)2804 watchdog_soft_reset (Process|3),(Pid|1|5),(MaxPss|1|2),(Pss|1|2),(Skip|3)2805 watchdog_hard_reset (Process|3),(Pid|1|5),(MaxPss|1|2),(Pss|1|2)2806 watchdog_pss_stats (EmptyPss|1|2),(EmptyCount|1|1),(BackgroundPss|1|2),(BackgroundCount|1|1),(ServicePss|1|2),(ServiceCount|1|1),(VisiblePss|1|2),(VisibleCount|1|1),(ForegroundPss|1|2),(ForegroundCount|1|1),(NoPssCount|1|1)2807 watchdog_proc_stats (DeathsInOne|1|1),(DeathsInTwo|1|1),(DeathsInThree|1|1),(DeathsInFour|1|1),(DeathsInFive|1|1)2808 watchdog_scheduled_reboot (Now|2|1),(Interval|1|3),(StartTime|1|3),(Window|1|3),(Skip|3)2809 watchdog_meminfo (MemFree|1|2),(Buffers|1|2),(Cached|1|2),(Active|1|2),(Inactive|1|2),(AnonPages|1|2),(Mapped|1|2),(Slab|1|2),(SReclaimable|1|2),(SUnreclaim|1|2),(PageTables|1|2)2810 watchdog_vmstat (runtime|2|3),(pgfree|1|1),(pgactivate|1|1),(pgdeactivate|1|1),(pgfault|1|1),(pgmajfault|1|1)2811 watchdog_requested_reboot (NoWait|1|1),(ScheduleInterval|1|3),(RecheckInterval|1|3),(StartTime|1|3),(Window|1|3),(MinScreenOff|1|3),(MinNextAlarm|1|3)# ---------------------------# BackupManagerService.java# ---------------------------2820 backup_data_changed (Package|3)2821 backup_start (Transport|3)2822 backup_transport_failure (Package|3)2823 backup_agent_failure (Package|3),(Message|3)2824 backup_package (Package|3),(Size|1|2)2825 backup_success (Packages|1|1),(Time|1|3)2826 backup_reset (Transport|3)2827 backup_initialize2828 backup_requested (Total|1|1),(Key-Value|1|1),(Full|1|1)2829 backup_quota_exceeded (Package|3)2830 restore_start (Transport|3),(Source|2|5)2831 restore_transport_failure2832 restore_agent_failure (Package|3),(Message|3)2833 restore_package (Package|3),(Size|1|2)2834 restore_success (Packages|1|1),(Time|1|3)2840 full_backup_package (Package|3)2841 full_backup_agent_failure (Package|3),(Message|3)2842 full_backup_transport_failure2843 full_backup_success (Package|3)2844 full_restore_package (Package|3)2845 full_backup_quota_exceeded (Package|3)2850 backup_transport_lifecycle (Transport|3),(Bound|1|1)# ---------------------------# SystemServer.java# ---------------------------# SystemServer.run() starts:3010 boot_progress_system_run (time|2|3)# ---------------------------# PackageManagerService.java# ---------------------------# Package Manager starts:3060 boot_progress_pms_start (time|2|3)# Package Manager .apk scan starts:3070 boot_progress_pms_system_scan_start (time|2|3)# Package Manager .apk scan starts:3080 boot_progress_pms_data_scan_start (time|2|3)# Package Manager .apk scan ends:3090 boot_progress_pms_scan_end (time|2|3)# Package Manager ready:3100 boot_progress_pms_ready (time|2|3)# + check activity_launch_time for Home app# Value of "unknown sources" setting at app install time3110 unknown_sources_enabled (value|1)# Package Manager critical info3120 pm_critical_info (msg|3)# ---------------------------# WindowManagerService.java# ---------------------------# Out of memory for surfaces.31000 wm_no_surface_memory (Window|3),(PID|1|5),(Operation|3)# Task created.31001 wm_task_created (TaskId|1|5),(StackId|1|5)# Task moved to top (1) or bottom (0).31002 wm_task_moved (TaskId|1|5),(ToTop|1),(Index|1)# Task removed with source explanation.31003 wm_task_removed (TaskId|1|5),(Reason|3)# Stack created.31004 wm_stack_created (StackId|1|5)# Home stack moved to top (1) or bottom (0).31005 wm_home_stack_moved (ToTop|1)# Stack removed.31006 wm_stack_removed (StackId|1|5)# bootanim finished:31007 wm_boot_animation_done (time|2|3)# ---------------------------# InputMethodManagerService.java# ---------------------------# Re-connecting to input method service because we haven't received its interface32000 imf_force_reconnect_ime (IME|4),(Time Since Connect|2|3),(Showing|1|1)# ---------------------------# WallpaperManagerService.java# ---------------------------33000 wp_wallpaper_crashed (component|3)# ---------------------------# Device idle# ---------------------------34000 device_idle (state|1|5), (reason|3)34001 device_idle_step34002 device_idle_wake_from_idle (is_idle|1|5), (reason|3)34003 device_idle_on_start34004 device_idle_on_phase (what|3)34005 device_idle_on_complete34006 device_idle_off_start (reason|3)34007 device_idle_off_phase (what|3)34008 device_idle_off_complete34009 device_idle_light (state|1|5), (reason|3)34010 device_idle_light_step# ---------------------------# DisplayManagerService.java# ---------------------------# Auto-brightness adjustments by the user.35000 auto_brightness_adj (old_adj|5),(old_lux|5),(old_brightness|5),(old_gamma|5),(new_adj|5),(new_lux|5),(new_brightness|5),(new_gamma|5)# ---------------------------# ConnectivityService.java# ---------------------------# Connectivity state changed50020 connectivity_state_changed (type|1),(subtype|1),(state|1)# ---------------------------# NetworkStatsService.java# ---------------------------51100 netstats_mobile_sample (dev_rx_bytes|2|2),(dev_tx_bytes|2|2),(dev_rx_pkts|2|1),(dev_tx_pkts|2|1),(xt_rx_bytes|2|2),(xt_tx_bytes|2|2),(xt_rx_pkts|2|1),(xt_tx_pkts|2|1),(uid_rx_bytes|2|2),(uid_tx_bytes|2|2),(uid_rx_pkts|2|1),(uid_tx_pkts|2|1),(trusted_time|2|3)51101 netstats_wifi_sample (dev_rx_bytes|2|2),(dev_tx_bytes|2|2),(dev_rx_pkts|2|1),(dev_tx_pkts|2|1),(xt_rx_bytes|2|2),(xt_tx_bytes|2|2),(xt_rx_pkts|2|1),(xt_tx_pkts|2|1),(uid_rx_bytes|2|2),(uid_tx_bytes|2|2),(uid_rx_pkts|2|1),(uid_tx_pkts|2|1),(trusted_time|2|3)# ---------------------------# LockdownVpnTracker.java# ---------------------------51200 lockdown_vpn_connecting (egress_net|1)51201 lockdown_vpn_connected (egress_net|1)51202 lockdown_vpn_error (egress_net|1)# ---------------------------# ConfigUpdateInstallReceiver.java# ---------------------------51300 config_install_failed (dir|3)# ---------------------------# IntentFirewall.java# ---------------------------51400 ifw_intent_matched (Intent Type|1|5),(Component Name|3),(Caller Uid|1|5),(Caller Pkg Count|1|1),(Caller Pkgs|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5)# ---------------------------# IdleMaintenanceService.java# ---------------------------51500 idle_maintenance_window_start (time|2|3), (lastUserActivity|2|3), (batteryLevel|1|6), (batteryCharging|1|5)51501 idle_maintenance_window_finish (time|2|3), (lastUserActivity|2|3), (batteryLevel|1|6), (batteryCharging|1|5)# ---------------------------# MountService.java# ---------------------------2755 fstrim_start (time|2|3)2756 fstrim_finish (time|2|3)# ---------------------------# AudioService.java# ---------------------------40000 volume_changed (stream|1), (prev_level|1), (level|1), (max_level|1), (caller|3)40001 stream_devices_changed (stream|1), (prev_devices|1), (devices|1)# ---------------------------# GestureLauncherService.java# ---------------------------40100 camera_gesture_triggered (gesture_on_time|2|3), (sensor1_on_time|2|3), (sensor2_on_time|2|3), (event_extra|1|1)
免责声明:本站部分内容、图片、文字、视频等来自于互联网,仅供大家学习与交流。相关内容如涉嫌侵犯您的知识产权或其他合法权益,请向本站发送有效通知,我们会及时处理。反馈邮箱&&&&。
学生服务号
在线咨询,奖学金返现,名师点评,等你来互动1635人阅读
本文介绍一个基于linux进程调度策略来调度的信息输出系统,多条信息可以显示多次,每次的显示时间也可以设置:
以下是头文件定义loglet.h:
#include &pthread.h&
#define MAX_PRIO 8
#define MAX_LENGTH 512
static inline void __set_bit(int nr, volatile unsigned long * addr)
static inline void clear_bit(int nr, volatile unsigned long * addr)
static inline void __clear_bit(int nr, volatile unsigned long * addr)
struct list_head {
#define list_entry(ptr, type, member) /
&& &&& &...
static inline void INIT_LIST_HEAD(struct list_head *list)
static inline void __list_add(struct list_head *new,
&& &&& &&& &&&&&& struct list_head *prev,
&& &&& &&& &&&&&& struct list_head *next)
static inline void list_add(struct list_head *new, struct list_head *head)
static inline void list_add_tail(struct list_head *new, struct list_head *head)
static inline void __list_del(struct list_head * prev, struct list_head * next)
static inline void list_del(struct list_head *entry)
static inline int list_empty(const struct list_head *head)
struct prio_array {
//log_buff定义一条日志任务
struct log_buff {
&& &char&& &buf[MAX_LENGTH]; //实际需要展示的数据
&& &int && & //这个日志任务的优先级
&& &int&& & //这个任务目前为止显示的次数
&& &int&& &sed_ //持续多久被调度出去
&& &int&& &need_ //是否被抢占
&& &int&& &remove_ //是否应该被删除
&& &int&& &alive_ //这个任务需要显示的次数
&& &int&& & //每次显示持续的时间
&& &struct list_&& &//全局链表
&& &struct prio_array * //目前属于哪个数组,活跃还是过期?
&& &struct list_head run_ //加入链表的锚
//log_queue定义一个全局的队列
struct log_queue {
&& &unsigned long&& &nr_ //一共有多少任务
&& &unsigned long long last_ //上次调度的时间
&& &struct log_buff&& &* //它的idle任务,没事干的时候显示
&& &struct prio_array *, *expired, arrays[2]; //活跃数组/过期数组
&& &void&& (*handler_init)(void *argv); //输出处理初始化回调函数,比如初始化网络,LCD屏幕等等
&& &void&& (*handler_process)(void *argv, int blink); //输出处理函数,比如写LCD屏幕等
&& &int&& (*prio2times)(int prio); //优先级转化为时间片的函数
&& &pthread_mutex_t queue_
//以下定义一系列导出函数
//全局初始化
int global_init();
//以下三个设置log_queue的回调函数
void set_handle_process(void&& (*handler_process)(void *argv, int blink));
void set_handle_init(void&& (*handler_init)(void *argv), void *arg);
void set_prio2times(int&& (*prio2times)(int prio));
//设置调度间隔
int set_interval(int val);
void set_idle(const char *info);
int insert_log(const char *info, int prio, int alives, int blink);&& &
以下是实现文件代码:
#include &log_let.h&
#include &stdlib.h&
#include &string.h&
#include &sys/time.h&
#include &signal.h&
#include &unistd.h&
#include &stdio.h&
struct log_buff *current = NULL;
struct log_buff *prev = NULL;
unsigned long long tick = 0;
struct log_queue& *global_
//从一个链表中将一个日志退出
static void dequeue_log(struct log_buff *p, struct prio_array *array)
&& &array-&nr_active--;
&& &list_del(&p-&run_list);
&& &if (list_empty(array-&queue + p-&prio))
&& &&& &__clear_bit(p-&prio, array-&bitmap);
//将一条日志加入一个链表
static void enqueue_log(struct log_buff *p, struct prio_array *array)
&& &struct list_head *lh = &global_rq-&active-&queue[p-&prio];
&& &list_add_tail(&p-&run_list, &array-&queue[p-&prio]);
&& &__set_bit(p-&prio, array-&bitmap);
&& &array-&nr_active ++;
&& &p-&array =
//得到默认队列
struct log_queue *get_queue()
&& &return global_
void remove_log(struct log_buff *buf)
&& &buf-&remove_flag = 1;
//信号处理函数
void time_tick(void)
&& &unsigned long long now = tick ++;
&& &struct log_buff *p =
&& &struct log_queue *rq = get_queue();//global_
&& &rq-&last_tick =
&& &//如果是idle日志,不处理
&& &//如果还没有任何日志,不处理
&& &//如果和前一次处理的一样,不重复处理
&& &if (p == rq-&idle || !p || p == prev) {
&& &prev =
&& &//如果时间片耗尽,则要么加入到&过期数组&,要么被删除
&& &if (!--p-&sed_slice) {
&& &&& &p-&need_go = 1;
&& &&& &//如果此条日志需要显示的次数到了,那么就要删除它了
&& &&& &if (p-&alive_times & 0 && !--p-&alive_times) {
&& &&& &&& &remove_log(p); //仅仅设置一个删除标志
&& &&& &&& &
&& &&& &//将一个&过期&的日志加入到一个&过期数组&中,注意需要锁操作
&& &&& &pthread_mutex_lock(&rq-&queue_mutex);&& &
&& &&& &dequeue_log(p, rq-&active);
&& &&& &pthread_mutex_unlock(&rq-&queue_mutex);&& &
&& &&& &//重新设置显示&时间片&信息
&& &&& &p-&sed_slice = rq-&prio2times(p-&prio);
&& &&& &pthread_mutex_lock(&rq-&queue_mutex);
&& &&& &enqueue_log(p, rq-&expired);
&& &&& &pthread_mutex_unlock(&rq-&queue_mutex);
//激活一条日志任务
static void __activate_log(struct log_buff *p, struct log_queue *rq)
&& &struct prio_array *target = rq-&
&& &pthread_mutex_lock(&rq-&queue_mutex);
&& &enqueue_log(p, target);
&& &pthread_mutex_unlock(&rq-&queue_mutex);
&& &rq-&nr_running++;
//实际的插入动作参数依次是(内容,优先级别,显示次数,每次显示滞留的时间,是否是idle)
int insert_log_real(const char *content, int prio, int alive_times, int blink, int idle)
&& &int ret = 0;
&& &struct log_queue *
&& &struct log_buff *
&& &if ((current == NULL && !idle) || (current && idle)) {
&& &&& &ret = -1;
&& &rq = get_queue();
&& &lb = (struct log_buff *)calloc(1, sizeof(struct log_buff));
&& &strncpy(lb-&buf, content, strlen(content)?:MAX_LENGTH);
&& &INIT_LIST_HEAD(&lb-&run_list);
&& &lb-&prio =
&& &lb-&times = 0;
&& &lb-&alive_times = alive_
&& &lb-&blink =
&& &lb-&sed_slice = (rq-&prio2times)(prio);//show_style_func(prio);& //可设置一个数学函数
&& &if (!idle) //idle任务并不加入到任何链表当中,方便操作
&& &&& &__activate_log(lb, rq);
&& &else {
&& &&& &current =
&& &&& &rq-&idle =
&& &//如果插入了一条信息且当前正在运行idle,则抢占它
&& &//如果当前的任务的优先级别没有新插入的任务的优先级别高,则抢占它
&& &if (current && ((current == rq-&idle&&!idle) || current-&prio&prio))
&& &&& &current-&need_go = 1;
//插入idle日志任务
void set_idle(const char *idlebuf)
&& &insert_log_real(idlebuf, 7, 0, 1, 1);
//插入一般的日志任务
int insert_log(const char *content, int prio, int alive_times, int blink)
&& &return insert_log_real(content, prio, alive_times, blink, 0);
//以下这些都是直接从linux内核源代码中copy出来的
static inline unsigned long __ffs(unsigned long word)
static inline int sched_find_first_bit(const unsigned long *b)
//设置输出初始化回调函数
void set_handle_init(void (*func)(void *argv), void *arg)
&& &struct log_queue* rq = get_queue();
&& &rq-&handler_init =
&& &rq-&handler_init(arg);
//设置输出处理函数
void set_handle_process(void (*func)(void *argv, int blink))
&& &struct log_queue* rq = get_queue();
&& &rq-&handler_process =
//设置从优先级到时间片的转换函数
void set_prio2times(int (*func)(int prio))
&& &struct log_queue* rq = get_queue();
&& &rq-&prio2times =
//全局的初始化
int global_init()
&& &int ret = 0;
&& &//分配全局队列
&& &global_rq = (struct log_queue*)calloc(1, sizeof(struct log_queue));
&& &struct prio_array *active = (struct prio_array*)malloc(sizeof(struct prio_array));
&& &struct prio_array *expired = (struct prio_array*)malloc(sizeof(struct prio_array));
&& &memset(active, 0, sizeof(struct prio_array));
&& &memset(expired, 0, sizeof(struct prio_array));
&& &global_rq-&active =
&& &global_rq-&expired =
&& &ret = pthread_mutex_init(&global_rq-&queue_mutex, NULL);
&& &//初始化活动数组
&& &for (i = 0; i & MAX_PRIO; i++) {
&& &&& &INIT_LIST_HEAD(&global_rq-&active-&queue[i]);
&& &//初始化过期数组
&& &for (i = 0; i & MAX_PRIO; i++) {
&& &&& &INIT_LIST_HEAD(&global_rq-&expired-&queue[i]);
//设置调度时间间隔并且开始调度
int set_interval(int second)
&& &static struct itimerval p_
&& &p_realt.it_interval.tv_sec =
&& &p_realt.it_interval.tv_usec = 0;
&& &p_realt.it_value.tv_sec =
&& &p_realt.it_value.tv_usec = 0;
&& &&& &signal(SIGALRM,time_tick);
&& &&& &if(setitimer(ITIMER_REAL,&p_realt,(struct itimerval *)0) == -1) {
&&&&&& &&& &perror(&setitimer error! &);
&& &&& &return -1;
&& &return 0;
//全局启动
int start()
&& &int ret = 0;
&& &struct log_buff *
&& &//以下的逻辑完全就是linux内核O(1)进程调度器的逻辑
&& &//参见linux内核kernel/sched.c中的schedule函数代码
&& &while (1) {
&& &&& &struct log_queue *rq = get_queue();
&& &&& &struct prio_array *array = rq-&
&& &&& &previous =
&& &&& &if (current-&need_go) {
&& &&& &&& &if (!array-&nr_active) {
&& &&& &&& &&& &rq-&active = rq-&
&& &&& &&& &&& &rq-&expired =
&& &&& &&& &&& &array = rq-&
&& &&& &&& &}
&& &&& &&& &struct log_buff *
&& &&& &&& &if (!array-&nr_active) {
&& &&& &&& &&& &lb = rq-&
&& &&& &&& &&& &goto switch_&& &&& &&& &&& &
&& &&& &&& &}
&& &&& &&& &int idx = sched_find_first_bit(array-&bitmap);
&& &&& &&& &struct list_head *queue = array-&queue +&& &
&& &&& &&& &lb = list_entry(queue-&next, struct log_buff, run_list);
&& &&& &&& &if (lb-&remove_flag) {
&& &&& &&& &&& &int redo_flag = 0;
&& &&& &&& &&& &if (lb == current) {
&& &&& &&& &&& &&& &redo_flag = 1;
&& &&& &&& &&& &}
&& &&& &&& &&& &pthread_mutex_lock(&rq-&queue_mutex);&& &
&& &&& &&& &&& &dequeue_log(lb, lb-&array);
&& &&& &&& &&& &pthread_mutex_unlock(&rq-&queue_mutex);&& &
&& &&& &&& &&& &free(lb);
&& &&& &&& &&& &lb = NULL;
&& &&& &&& &&& &if(redo_flag)
&& &&& &&& &&& &&& &
&& &&& &&& &}
switch_to:
&& &&& &&& &lb-&need_go = 0;
&& &&& &&& &current =
&& &&& &if (current == previous && current == rq-&idle) {
&& &&& &&& &usleep(500);
&& &&& &&& &
&& &&& &rq-&handler_process(current-&buf, current-&blink);
下面是一个测试程序
#include &lcd_task.h&
#include &stdlib.h&
#include &stdio.h&
#include &malloc.h&
#include &unistd.h&
#include &string.h&
#include &sys/types.h&
#include &sys/stat.h&
#include &fcntl.h&
#include &termios.h&
#include &errno.h&
int show_style_func(int prio)
&& &return 1;//9-
void lcd_init(void *argv)
&& &//打开并设置屏幕
&& &... open( ..., O_RDWR | O_NOCTTY | O_NDELAY);
void lcd_process(void *argv, int blink)
&& &//argv就是需要输出的信息,blink就是输出的间隔
&& &char *buf = (char*)
&& &for (i = 0; i & 需要的屏幕数; i++, ...) {
&& &&& &//换屏处理,每屏幕都显示blink的间隔,下面的处理为了防止被调度timer信号中断sleep
&& &&& &while(blink = sleep(blink));
&& &&& &blink =
void *test_func(void *arg)
&& &int i,
&& &int total = 20;
&& &char buf[16];
&& &while (total--) {
&& &&& &prio =& random()%8;
&& &&& &for (i = 0; i & 8; i++) {
&& &&& &&& &if(prio == i) {
&& &&& &&& &&& &memset(buf, 0, sizeof(buf));
&& &&& &&& &&& &for (j = 0; j & 2*i; j++) {
&& &&& &&& &&& &&& &strcat(buf, &-&);
&& &&& &&& &&& &}
&& &&& &&& &&& &if (i == 0)
&& &&& &&& &&& &&& &strcat(buf, &0000&);
&& &&& &&& &&& &insert_log(buf, prio, 2, 2);
&& &&& &&& &&& &
&& &&& &&& &}
&& &&& &sleep(1);
int main(int argc, char **argv)
&& &pthread_
&& &global_init();
&& &set_handle_process(lcd_process);
&& &set_handle_init(lcd_init, NULL);
&& &set_prio2times(show_style_func);
&& &set_interval(1);
&& &set_idle(&I'm IDLE&);
&& &insert_log(&this is one&, 4, 3, 5);
&& &pthread_create(&id,NULL,test_func,NULL);
&& &start();
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:4974822次
积分:63103
积分:63103
排名:第26名
原创:1337篇
评论:2311条
(11)(13)(6)(17)(14)(9)(12)(1)(1)(2)(5)(1)(8)(2)(22)(9)(8)(2)(7)(10)(12)(14)(21)(7)(1)(2)(9)(13)(10)(12)(11)(10)(5)(11)(14)(14)(1)(16)(12)(7)(15)(11)(5)(1)(5)(2)(11)(10)(6)(7)(6)(16)(4)(15)(15)(16)(8)(22)(25)(7)(13)(10)(13)(13)(19)(19)(9)(11)(29)(10)(16)(9)(19)(28)(26)(28)(27)(39)(7)(414)(1)(10)}

我要回帖

更多关于 .log是什么文件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信