What is the procedure for finding the maximum or minimum

What is the procedure for finding the maximum or minimum of a function? How is the second derivative used in this process?