本文整理汇总了C++中pid函数的典型用法代码示例。如果您正苦于以下问题:C++ pid函数的具体用法?C++ pid怎么用?C++ pid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _
Port AuthHostInstance::activate()
{
StLock<Mutex> _(*this);
if (state() != alive)
{
if ((mHostType == securityAgent)) {
if (!(session().attributes() & sessionHasGraphicAccess))
CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION);
if (inDarkWake())
CssmError::throwMe(CSSM_ERRCODE_IN_DARK_WAKE);
}
fork();
switch (ServerChild::state()) {
case Child::alive:
secdebug("AuthHostInstance", "%p (pid %d) has launched", this, pid());
break;
case Child::dead:
secdebug("AuthHostInstance", "%p (pid %d) failed on startup", this, pid());
break;
default:
assert(false);
}
}
if (!ready())
CssmError::throwMe(CSSM_ERRCODE_NO_USER_INTERACTION);
return servicePort();
}
示例2: clear_breakpoints
//------------------------------------------------------------------------------
// Name: kill
// Desc:
//------------------------------------------------------------------------------
void DebuggerCore::kill() {
if(attached()) {
clear_breakpoints();
ptrace(PT_KILL, pid(), 0, 0);
native::waitpid(pid(), 0, WAIT_ANY);
pid_ = 0;
threads_.clear();
}
}
示例3: pid
EXPORT_C void RMemSpySession::GetProcessIdByThreadId( TProcessId& aPID, TThreadId aTID )
{
TPckgBuf<TProcessId> pid(aPID);
TPckgBuf<TThreadId> tid(aTID);
TIpcArgs args( &pid, &tid );
User::LeaveIfError( SendReceive( EMemSpyClientServerOpGetProcessIdByThreadId, args ) );
aPID = pid();
}
示例4: _pid
/*******************************************************************************
forkcmd
*******************************************************************************/
forkcmd::forkcmd(bool wait_term) :
_pid(fork()),
_status(0),
_wait(wait_term)
{
if (pid())
{
std::cout << "Forked " << pid() << std::endl ;
PCOMN_THROW_MSG_IF(pid() < 0, std::runtime_error, "Error while forking: %s", strerror(errno)) ;
}
}
示例5: _
//
// Take a living child and cut it loose. This sets its state to abandoned
// and removes it from the child registry.
// This is one thing you can do in the destructor of your subclass to legally
// dispose of your child's process.
//
void Child::abandon()
{
StLock<Mutex> _(mChildren());
if (mState == alive) {
secdebug("unixchild", "%p (pid %d) abandoned", this, pid());
mState = abandoned;
mChildren().erase(pid());
} else {
secdebug("unixchild", "%p (pid %d) is not alive; abandon() ignored",
this, pid());
}
}
示例6: set_group
dvl::pid_table::pid_table()
{
//register internal ids
set_group(pid().set_group(GROUP_INTERNAL), L"INTERNAL");
set_element(EMPTY, L"EMPTY");
set_element(PARSER, L"PARSER");
//register diagnostic routines
set_group(pid().set_group(GROUP_DIAGNOSTIC), L"DIAGNOSTIC");
set_element(ECHO, L"ECHO");
}
示例7: pid
Monitor::TreeNode*
Monitor::MonitorDataStorage::getTransportNode(
const TransportKey& key,
bool& create
)
{
TreeNode* node = 0;
TransportToTreeMap::iterator location
= this->transportToTreeMap_.find( key);
if( location == this->transportToTreeMap_.end()) {
// We are done if not creating a new node.
if( !create) return 0;
// This transport needs to be installed.
// Find the parent node, if any. It is ok to not have a parent node
// for cases of out-of-order updates. We handle that as the updates
// are actually processed.
ProcessKey pid( key.host, key.pid);
TreeNode* parent = this->getProcessNode( pid, create);
QList<QVariant> list;
QString value = QString("0x%1")
.arg( key.transport, 8, 16, QLatin1Char('0'));
list << QString( QObject::tr( "Transport")) << value;
node = new TreeNode( list, parent);
if( parent) {
parent->append( node);
}
// Install the new node.
this->transportToTreeMap_[ key] = std::make_pair( node->row(), node);
} else {
node = location->second.second;
create = false;
}
// If there have been some out-of-order reports, we may have been
// created without a parent node. We can fill in that information now
// if we can. If we created the node, we already know it has a
// parent so this will be bypassed.
if( !node->parent()) {
create = true;
ProcessKey pid( key.host, key.pid);
node->parent() = this->getProcessNode( pid, create);
}
//node->setColor(1,QColor("#ffbfbf"));
return node;
}
示例8: main
int main(int argc, char **argv) {
if(argc < 5) {
std::cout << "Invalid number of args." << std::endl;
return 0;
}
auto maxPwm = atof(argv[1]);
if(maxPwm < 1.34 || maxPwm > 1.7) {
std::cout << "Max pulse width needs to be in range 1.34-1.7." << std::endl;
return 0;
}
auto pGain = atof(argv[2]);
if(pGain < 0) {
std::cout << "Proportional gain needs to be larget than zero." << std::endl;
return 0;
}
auto iGain = atof(argv[3]);
if(iGain < 0) {
std::cout << "Integral gain needs to be larget than zero." << std::endl;
return 0;
}
auto dGain = atof(argv[4]);
if(dGain < 0) {
std::cout << "Derivative gain needs to be larget than zero." << std::endl;
return 0;
}
drone<servo, pid> d(std::vector<servo>({
servo(4, 1.2, maxPwm, pins::instance().pwm),
servo(5, 1.2, maxPwm, pins::instance().pwm),
servo(6, 1.2, maxPwm, pins::instance().pwm),
servo(7, 1.2, maxPwm, pins::instance().pwm) }),
std::vector<pid>({
pid(pGain, iGain, dGain),
pid(pGain, iGain, dGain),
pid(pGain, iGain, dGain) }));
stupid = &d;
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = ting;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
d.run();
}
示例9: assert
//
// Common kill code.
// Requires caller to hold mChildren() lock.
//
void Child::tryKill(int signal)
{
assert(mState == alive); // ... or don't bother us
secdebug("unixchild", "%p (pid %d) sending signal(%d)", this, pid(), signal);
if (::kill(pid(), signal))
switch (errno) {
case ESRCH: // someone else reaped ths child; or things are just wacky
secdebug("unixchild", "%p (pid %d) has disappeared!", this, pid());
mState = invalid;
mChildren().erase(pid());
// fall through
default:
UnixError::throwMe();
}
}
示例10: clear_breakpoints
//------------------------------------------------------------------------------
// Name: kill
// Desc:
//------------------------------------------------------------------------------
void DebuggerCore::kill() {
if(attached()) {
clear_breakpoints();
ptrace(PTRACE_KILL, pid(), 0, 0);
// TODO: do i need to actually do this wait?
native::waitpid(pid(), 0, __WALL);
delete process_;
process_ = 0;
reset();
}
}
示例11: syscall
//------------------------------------------------------------------------------
// Name: stop_threads
// Desc:
//------------------------------------------------------------------------------
void DebuggerCore::stop_threads() {
if(process_) {
for(auto &thread: process_->threads()) {
const edb::tid_t tid = thread->tid();
if(!waited_threads_.contains(tid)) {
if(auto thread_ptr = static_cast<PlatformThread *>(thread.get())) {
syscall(SYS_tgkill, pid(), tid, SIGSTOP);
int thread_status;
if(native::waitpid(tid, &thread_status, __WALL) > 0) {
waited_threads_.insert(tid);
thread_ptr->status_ = thread_status;
if(!WIFSTOPPED(thread_status) || WSTOPSIG(thread_status) != SIGSTOP) {
qDebug("[warning] paused thread [%d] received an event besides SIGSTOP", tid);
}
}
}
}
}
}
}
示例12: TEST
TEST (PID, PidEquilibrates)
{
float target, Kp, Ki, Kd;
float state, dt;
int step_time, nsteps;
const float target_start = 0.f;
const float target_end = 1.f;
const float tolerance = 1e-5;
state = target = 0.f;
step_time = 20;
nsteps = 200;
dt = 0.1;
Kp = 3.f;
Ki = 2.f;
Kd = 3.f;
PidControl<float> pid(target-state, Kp, Ki, Kd);
for (int i = 0; i < nsteps; ++i) {
target = i < step_time ? target_start : target_end;
state += dt * pid.update(target-state);
// printf("%g\n", state);
}
ASSERT_LE(fabs(state - target_end), tolerance);
}
示例13: roll
/** Caculate the PID for the roll */
inline float roll(const float &roll) {
#ifdef PITCH_ROLL_DEBUG
Serial.print(_roll);
Serial.print(",");
#endif
return pid(P_ROLL, I_ROLL, D_ROLL, _pid_roll[0], _pid_roll[1], roll, _roll * DEG_SEC);
}
示例14: pitch
/** Caculate the PID for the pitch */
inline float pitch(const float &pitch) {
#ifdef PITCH_ROLL_DEBUG
Serial.print(_pitch);
Serial.print(",");
#endif
return pid(P_PITCH, I_PITCH, D_PITCH, _pid_pitch[0], _pid_pitch[1], pitch, _pitch * DEG_SEC);
}
示例15: yaw
/** Caculate the PID for the yaw */
inline float yaw(const float &yaw) {
#ifdef PITCH_ROLL_DEBUG
Serial.print(_yaw);
Serial.println();
#endif
return pid(P_YAW, I_YAW, D_YAW, _pid_yaw[0], _pid_yaw[1], yaw, _yaw * DEG_SEC);
}