Sponsored Content
Full Discussion: Which is more expensive ?
Top Forums Programming Which is more expensive ? Post 302131717 by vino on Monday 13th of August 2007 10:24:55 AM
Old 08-13-2007
Quote:
Originally Posted by cbkihong
But isn't that this will only close fd up to 135? Smilie
My very bad.

I actually meant a loop which runs for 1024 against another loop which runs for 128 times in which 8 fd's are closed each time.

Code:
        for (int fd = 0; fd <= 1024; fd += 8)
        {
            close(fd);
            close(fd+1);
            close(fd+2);
            close(fd+3);
            close(fd+4);
            close(fd+5);
            close(fd+6);
            close(fd+7);
        }

I know the close call gets called 1024 times. But what about the looping part ? Is there any benefit at all ?
 

2 More Discussions You Might Find Interesting

1. Programming

calling pthread_self (on ubuntu), expensive?

Hi all, Is anyone aware of what operations are involved when a call to pthread_self() is made, obtaining the unique thread ID on a Ubuntu system (or even any Linux flavour)? Specifically, to retrieve the thread id, is there any locking required or atomic operations? I'm building an... (11 Replies)
Discussion started by: gorga
11 Replies

2. What is on Your Mind?

Very Expensive Running Shoes

You really should not need one third of the entire US budget to buy a pair of running shoes... even if they are name brand. What have these guys been smoking? It reminds me of the old joke... Customer: At those prices you aren't going to sell many shoes. Salesman: Ah, but all we need to do is... (4 Replies)
Discussion started by: Perderabo
4 Replies
GLUBEGINTRIM(3G)														  GLUBEGINTRIM(3G)

NAME
gluBeginTrim, gluEndTrim - delimit a NURBS trimming loop definition C SPECIFICATION
void gluBeginTrim( GLUnurbs* nurb ) void gluEndTrim( GLUnurbs* nurb ) PARAMETERS
nurb Specifies the NURBS object (created with gluNewNurbsRenderer). DESCRIPTION
Use gluBeginTrim to mark the beginning of a trimming loop, and gluEndTrim to mark the end of a trimming loop. A trimming loop is a set of oriented curve segments (forming a closed curve) that define boundaries of a NURBS surface. You include these trimming loops in the defini- tion of a NURBS surface, between calls to gluBeginSurface and gluEndSurface. The definition for a NURBS surface can contain many trimming loops. For example, if you wrote a definition for a NURBS surface that resem- bled a rectangle with a hole punched out, the definition would contain two trimming loops. One loop would define the outer edge of the rec- tangle; the other would define the hole punched out of the rectangle. The definitions of each of these trimming loops would be bracketed by a gluBeginTrim/gluEndTrim pair. The definition of a single closed trimming loop can consist of multiple curve segments, each described as a piecewise linear curve (see gluPwlCurve) or as a single NURBS curve (see gluNurbsCurve), or as a combination of both in any order. The only library calls that can appear in a trimming loop definition (between the calls to gluBeginTrim and gluEndTrim) are gluPwlCurve and gluNurbsCurve. The area of the NURBS surface that is displayed is the region in the domain to the left of the trimming curve as the curve parameter increases. Thus, the retained region of the NURBS surface is inside a counterclockwise trimming loop and outside a clockwise trimming loop. For the rectangle mentioned earlier, the trimming loop for the outer edge of the rectangle runs counterclockwise, while the trimming loop for the punched-out hole runs clockwise. If you use more than one curve to define a single trimming loop, the curve segments must form a closed loop (that is, the endpoint of each curve must be the starting point of the next curve, and the endpoint of the final curve must be the starting point of the first curve). If the endpoints of the curve are sufficiently close together but not exactly coincident, they will be coerced to match. If the endpoints are not sufficiently close, an error results (see gluNurbsCallback). If a trimming loop definition contains multiple curves, the direction of the curves must be consistent (that is, the inside must be to the left of all of the curves). Nested trimming loops are legal as long as the curve orientations alternate correctly. If trimming curves are self-intersecting, or intersect one another, an error results. If no trimming information is given for a NURBS surface, the entire surface is drawn. EXAMPLE
This code fragment defines a trimming loop that consists of one piecewise linear curve, and two NURBS curves: gluBeginTrim(nobj); gluPwlCurve(..., GLU_MAP1_TRIM_2); gluNurbsCurve(..., GLU_MAP1_TRIM_2); gluNurbsCurve(..., GLU_MAP1_TRIM_3); gluEndTrim(nobj); SEE ALSO
gluBeginSurface(3G), gluNewNurbsRenderer(3G), gluNurbsCallback(3G), gluNurbsCurve(3G), gluPwlCurve(3G) GLUBEGINTRIM(3G)
All times are GMT -4. The time now is 11:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy