static void show_min_max(void) { unsigned long i; int policies[] = { SCHED_OTHER, SCHED_FIFO, SCHED_RR, #ifdef SCHED_BATCH SCHED_BATCH, #endif #ifdef SCHED_IDLE SCHED_IDLE, #endif #ifdef SCHED_DEADLINE SCHED_DEADLINE, #endif }; for (i = 0; i < ARRAY_SIZE(policies); i++) { int plc = policies[i]; int max = sched_get_priority_max(plc); int min = sched_get_priority_min(plc); if (max >= 0 && min >= 0) printf(_("SCHED_%s min/max priority\t: %d/%d\n"), get_policy_name(plc), min, max); else printf(_("SCHED_%s not supported?\n"), get_policy_name(plc)); } }
QWidget *RuleDelegate::createEditor(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (!index.isValid()) return editor; int column = index.model()->headerData(index.column(),Qt::Horizontal,bfmodel::IdRole).toInt(); if (column == bfmodel::OFF) { QComboBox *pe = new QComboBox(editor); int current = index.model()->data(index, Qt::DisplayRole).toUInt(); QStringList lst; lst << get_sw_name(SW_NO) << get_sw_name(SW_YES); if (pe) { pe->addItems(lst); pe->setCurrentIndex(current); } return pe; } else if (column == bfmodel::POLICY) { QComboBox *pe = new QComboBox(editor); int current = index.model()->data(index, Qt::DisplayRole).toUInt(); QStringList lst; lst << get_policy_name(POLICY_DROP) << get_policy_name(POLICY_ACCEPT); if (pe) { pe->addItems(lst); pe->setCurrentIndex(current); } return pe; } return editor; }
void RuleDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyleOptionViewItemV4 o = option; o.text = index.model()->data(index, Qt::DisplayRole).toString(); o.displayAlignment = Qt::AlignCenter; int column = index.model()->headerData(index.column(),Qt::Horizontal,bfmodel::IdRole).toInt(); // if (index.column() < 6) o.state = QStyle::State_ReadOnly; QVariantList l = index.model()->data(index, bfmodel::DirtyRole).toList(); if (l.contains(column)) o.font.setBold(true); int value = index.model()->data(index, Qt::DisplayRole).toInt(); switch(column) { case bfmodel::SRCIP: if(value ==0) o.text = "ALL"; else o.text = QHostAddress(static_cast<quint32>(value)).toString(); break; case bfmodel::SRCPORT: if(value ==0) o.text = "ALL"; break; case bfmodel::DSTIP: if(value ==0) o.text = "ALL"; else o.text = QHostAddress(static_cast<quint32>(value)).toString(); break; case bfmodel::DSTPORT: if(value ==0) o.text = "ALL"; break; case bfmodel::PROTO: o.text = get_proto_name(value); break; case bfmodel::CHAIN: o.text = get_chain_name(static_cast<bf_chain_t>(value)); break; case bfmodel::POLICY: o.text = get_policy_name(static_cast<bf_policy_t>(value)); break; case bfmodel::OFF: o.text = get_sw_name(static_cast<bf_switch_rules_t>(value)); break; } QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &o, painter); }
static void show_sched_pid_info(struct chrt_ctl *ctl, pid_t pid) { int policy, reset_on_fork = 0, prio = 0; #ifdef SCHED_DEADLINE uint64_t deadline = 0, runtime = 0, period = 0; #endif /* don't display "pid 0" as that is confusing */ if (!pid) pid = getpid(); #ifdef HAVE_SCHED_SETATTR { struct sched_attr sa; if (sched_getattr(pid, &sa, sizeof(sa), 0) != 0) err(EXIT_FAILURE, _("failed to get pid %d's policy"), pid); policy = sa.sched_policy; prio = sa.sched_priority; reset_on_fork = sa.sched_flags & SCHED_FLAG_RESET_ON_FORK; deadline = sa.sched_deadline; runtime = sa.sched_runtime; period = sa.sched_period; } #else /* !HAVE_SCHED_SETATTR */ { struct sched_param sp; policy = sched_getscheduler(pid); if (policy == -1) err(EXIT_FAILURE, _("failed to get pid %d's policy"), pid); if (sched_getparam(pid, &sp) != 0) err(EXIT_FAILURE, _("failed to get pid %d's attributes"), pid); else prio = sp.sched_priority; # ifdef SCHED_RESET_ON_FORK if (policy == (SCHED_FIFO|SCHED_RESET_ON_FORK) || policy == (SCHED_BATCH|SCHED_RESET_ON_FORK)) reset_on_fork = 1; # endif } #endif /* !HAVE_SCHED_SETATTR */ if (ctl->altered) printf(_("pid %d's new scheduling policy: %s"), pid, get_policy_name(policy)); else printf(_("pid %d's current scheduling policy: %s"), pid, get_policy_name(policy)); if (reset_on_fork) printf("|SCHED_RESET_ON_FORK"); putchar('\n'); if (ctl->altered) printf(_("pid %d's new scheduling priority: %d\n"), pid, prio); else printf(_("pid %d's current scheduling priority: %d\n"), pid, prio); #ifdef SCHED_DEADLINE if (policy == SCHED_DEADLINE) { if (ctl->altered) printf(_("pid %d's new runtime/deadline/period parameters: %ju/%ju/%ju\n"), pid, runtime, deadline, period); else printf(_("pid %d's current runtime/deadline/period parameters: %ju/%ju/%ju\n"), pid, runtime, deadline, period); } #endif }