static bool
remove_slowest_parents(t_rg_node * node, bool original_root_flag){
    
    if(node->visited != original_root_flag){
        printf("stumble on a node %d already visited\n",node->inode);
        return false;
    }else{
        /* Flip visited switch*/
        node->visited = !original_root_flag;
        bool ret = false;
        if(node->no_parents > 1){
            printf("remove_slowest_parents: node %d has %d parents.\n",node->inode,node->no_parents);
            // Find fastest parent
            t_linked_rg_edge_ref * pref = node->u.parent_list;
            t_linked_rg_edge_ref * fastest = NULL;
            
            float lowestDelay = 1000.0;
            while(pref!=NULL){
                t_rg_node* parent = pref->edge->u.parent;
                if(parent->Tdel<lowestDelay){
                    lowestDelay = parent->Tdel;
                    fastest = pref;
                }
                printf("parent %d: Tdel %.10e, edge %d\n",parent->inode,parent->Tdel,pref->edge->usage);
                pref = pref->next;
            }
            printf("fastest parent %d: Tdel %.10e, edge %d\n",fastest->edge->u.parent->inode,fastest->edge->u.parent->Tdel,fastest->edge->usage);
            //Delete all other parents that are slower
            pref = node->u.parent_list;
            t_linked_rg_edge_ref * next;
            while(pref!=NULL){
                next = pref->next;  
                if(pref != fastest){
                    printf("Removing parent %d from node %d (no_parents from %d to %d)\n",pref->edge->u.parent->inode, node->inode, node->no_parents,node->no_parents-1);
                    node->no_parents--;
                    
                    remove_parent(pref);
                }
                pref = next;
            }
            node->u.parent_list = fastest;
            fastest->next = NULL;
            ret = true;
        }
        
        /* Recursive call for all children */
        t_linked_rg_edge_ref* child = node->child_list;
        if(child != NULL){
            bool multiple_parent_downstream = false; 
            while(child!=NULL){
                printf("node %d, calling remove_slowest_parents node for %d\n",node->inode, child->edge->child->inode);
                multiple_parent_downstream = remove_slowest_parents(child->edge->child,original_root_flag);
                ret = ret || multiple_parent_downstream;
                child=child->next;
            }
        } 
        
        return ret;
    }
}
Example #2
0
/*
 * ptrace a task: make the debugger its new parent and
 * move it to the ptrace list.
 *
 * Must be called with the tasklist lock write-held.
 */
void __ptrace_link(struct task_struct *child, struct task_struct *new_parent)
{
	BUG_ON(!list_empty(&child->ptrace_list));
	if (child->parent == new_parent)
		return;
	list_add(&child->ptrace_list, &child->parent->ptrace_children);
	remove_parent(child);
	child->parent = new_parent;
	add_parent(child);
}
static void
remove_parent(t_linked_rg_edge_ref * pref)
{
    t_rg_node* parent = pref->edge->u.parent;
    t_rg_edge* edge = pref->edge;   
    int no_children = 0;
    //remove child edge ref of the parent
    t_linked_rg_edge_ref* prev = NULL;
    t_linked_rg_edge_ref * child_edge = parent->child_list;
    while(child_edge!=NULL){
        no_children++;
        if(child_edge->edge == edge){
            if(prev == NULL){
                parent->child_list = child_edge->next;
                child_edge->next = NULL;  
                //EV: Leaking here, could be prevented by keeping track of the tail of the free_link_list
                free(child_edge);
                child_edge = parent->child_list;
            }else{
                prev->next = child_edge->next;
                free_rg_link(child_edge);
                child_edge = prev->next;
            }        
        }else{
            prev = child_edge;
            child_edge=child_edge->next;
        }
    }
    //remove edge
    free_rg_edge(edge);
    //remove parent edge ref of the child
    pref->next = NULL;
    free(pref);
    
    if(no_children==1){
        //Remove node and check parent
        if(parent->no_parents>1){
            vpr_printf_warning(__FILE__,__LINE__,"Remove_parent: Not yet implemented for non used nodes with multiple parents!");
        }else{
            t_linked_rg_edge_ref * p_gparent = parent->u.parent_list;
            
            free_rg_node(parent);
            //Recursive call
            remove_parent(p_gparent);
        }
        
        
    }
    
    
}
Example #4
0
/*
 * unptrace a task: move it back to its original parent and
 * remove it from the ptrace list.
 *
 * Must be called with the tasklist lock write-held.
 */
void __ptrace_unlink(struct task_struct *child)
{
	BUG_ON(!child->ptrace);

	child->ptrace = 0;
	if (!list_empty(&child->ptrace_list)) {
		list_del_init(&child->ptrace_list);
		remove_parent(child);
		child->parent = child->real_parent;
		add_parent(child);
	}

	if (child->state == TASK_TRACED)
		ptrace_untrace(child);
}
static bool
remove_secundary_parents(t_rg_node * node, t_rg_edge * via_edge, bool original_root_flag){
    
    if(node->visited != original_root_flag){
        //printf("stumble on a node %d already visited\n",node->inode);
        return false;
    }else{
        /* Flip visited switch*/
        node->visited = !original_root_flag;
        bool ret = false;
        if(node->no_parents > 1){
            // delete parents that we did not go through 
            t_linked_rg_edge_ref * via_ref = NULL;
            t_linked_rg_edge_ref * pref = node->u.parent_list;
            t_linked_rg_edge_ref * next = NULL;
            while(pref!=NULL){
                next = pref->next;  
                if(pref->edge != via_edge){
                    //printf("Removing parent %d from node %d (no_parents from %d to %d)\n",pref->edge->u.parent->inode, node->inode, node->no_parents,node->no_parents-1);
                    node->no_parents--;
                    remove_parent(pref);
                }else{
                  via_ref = pref; 
                }
                pref = next;
            }
            node->u.parent_list = via_ref;
            ret = true;
        }
        
        /* Recursive call for all children */
        t_linked_rg_edge_ref* child = node->child_list;
        if(child != NULL){
            bool multiple_parent_downstream = false; 
            while(child!=NULL){
                //printf("node %d, calling remove_slowest_parents node for %d\n",node->inode, child->edge->child->inode);
                multiple_parent_downstream = remove_secundary_parents(child->edge->child, child->edge, original_root_flag);
                ret = ret || multiple_parent_downstream;
                child=child->next;
            }
        } 
        
        return ret;
    }
}
Example #6
0
/*
 * Unregisters the article specified by the mnemonic and
 * "other".  This function fulfills the "unregister" prodreg
 * command.
 *
 * "other" can be: "-": wildcard - matches any Article registered
 *			with the specified mnemonic.  Seems
 *			dangerous, but that's the way it works.
 *		 uninstaller directory
 *		 id (9-digit random number assigned to the article)
 *
 * This is not a good function prototype, but we cannot change
 * the functionality of the original product registry.  See
 * Article.java:lookupByUnloc for the original comments.
 */
static void
unregister_articles(const char *mnemonic, const char *other)
{
	if (mnemonic != NULL && other != NULL) {
		Wsreg_component *comp = get_component_by_other(mnemonic, other);
		if (comp != NULL) {
			/*
			 * Found the correct
			 * component.  Now unregister.
			 */
			remove_parent(comp);
			unregister(comp);
		} else {
			/*
			 * The specified component is not registered.
			 */
			(void) fprintf(stderr, PRODREG_NO_SUCH_COMPONENT,
			    mnemonic, other);
			(void) fprintf(stderr, "\n");
		}
	}
}
Example #7
0
bool mspectrumcondition::condition(mspectrum &_s)
{
/*
 * bail out if conditioning has been turned off
 */
	if(m_bUsePhosphoDetection)	{
		if(!find_loss(_s,98.0,3.0))	{
			return false;
		}
	}
	_s.m_vMINeutral.clear();
	sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMImz);
	if(_s.m_dMH < 1.0 && !_s.m_vMI.empty())	{
		m_bCharge = true;
		if(_s.m_fZ == 2.0)	{
			_s.m_dMH = _s.m_vMI[_s.m_vMI.size()-1].m_fM*1.2;
		}
		else if(_s.m_fZ == 3.0)	{
			_s.m_dMH = _s.m_vMI[_s.m_vMI.size()-1].m_fM*1.7;
		}
	}
	if(_s.m_vdStats.size() == 0)	{
		vector<mi>::iterator itMI = _s.m_vMI.begin();
		vector<mi>::iterator itEnd = _s.m_vMI.end();
		double dSum = 0.0;
		double dMax = 0.0;
		while(itMI != itEnd)	{
			if(dMax < itMI->m_fI)	{
				dMax = itMI->m_fI;
			}
			dSum += itMI->m_fI;
			itMI++;
		}
		_s.m_vdStats.push_back(dSum);
		_s.m_vdStats.push_back(dMax);
		_s.m_vdStats.push_back(m_fFactor);
	}
	if(_s.m_fZ > m_fMaxZ)	{
		return false;
	}
	if(!m_bCondition)	{
		return true;
	}
/*
 * check the parent ion charge and return false if it is too large
 */
	if(m_bUseNoiseSuppression)	{
		/*
		 * check the parent ion mass against the minimum mass allowed (about 600.0 is usually safe)
		*/
		if(m_bUseMinMass)	{
			if(_s.m_dMH < m_fMinMass)
				return false;
		}
		if(m_bUseChargeSuppression)	{
			if((long)(_s.m_fZ+0.5) > m_lMaxCharge)	{
				return false;
			}
		}
	}
	size_t tSize = _s.m_vMI.size();
	size_t a = 0;
	float fMaxI = 0;
/*
 * this method doesn't really remove isotopes: it cleans up multiple intensities within one Dalton
 * of each other.
 */
//	sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMImz);
	if(m_bUseIsotopes)	{
		remove_isotopes(_s);
	}
/*
 * remove ions near the parent ion m/z
 */
	if(m_bUseParent)	{
		remove_parent(_s);
	}
/*
 * remove low mass immonium ions prior to normalization
 */
	if(m_bUseLowestMass)	{
		remove_low_masses(_s);
	}
/*
 * normalize the spectrum 
 */
	vector<mi>::iterator itMI = _s.m_vMI.begin();
	vector<mi>::iterator itEnd = _s.m_vMI.end();
	double dSum = 0.0;
	double dMax = 0.0;
	while(itMI != itEnd)	{
		if(dMax < itMI->m_fI)	{
			dMax = itMI->m_fI;
		}
		dSum += itMI->m_fI;
		itMI++;
	}
	_s.m_vdStats.clear();
	_s.m_vdStats.push_back(dSum);
	_s.m_vdStats.push_back(dMax);
	_s.m_vdStats.push_back(m_fFactor);
	if(m_bUseDynamicRange)	{
		dynamic_range(_s);
	}
	if(m_bUseNeutralLoss)	{
		remove_neutral(_s);
	}
/*
* reject the spectrum if there aren't enough peaks 
*/
	if(m_bUseMinSize)	{
		if((long)_s.m_vMI.size() < m_lMinSize)
			return false;
	}
/*
 * check to see if the spectrum has the characteristics of noise 
 */
	if(m_bUseNoiseSuppression)	{
		if(is_noise(_s))	{
			return false;
		}
	}
/*
* retrieve the N most intense peaks
*/
	if(m_bUseIsotopes)	{
		clean_isotopes(_s);
	}
	if(m_bUseMaxPeaks)	{
		sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMI);
		remove_small(_s);
	}
	sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMImz);
	itMI = _s.m_vMI.begin();
	itEnd = _s.m_vMI.end();
	dSum = 0.0;
	dMax = 0.0;
	while(itMI != itEnd)	{
		if(dMax < itMI->m_fI)	{
			dMax = itMI->m_fI;
		}
		dSum += itMI->m_fI;
		itMI++;
	}
	_s.m_vdStats[0] = dSum*m_fFactor;
	_s.m_vdStats[1] = dMax*m_fFactor;
	_s.m_vdStats[2] = m_fFactor;
	return true;
}