A whistle is used to signal others that you are in distress and need assistance. It is also used to answer signals from those in distress. Shouting, yelling, and other forms of vocal alerting do not have the same range and require a much more fatiguing effort than blowing on a whistle.
Your whistle has to be attached to a lanyard and be easily reachable. You can wear it around your neck or attach to your belt or any other part of your clothing. Having a whistle in your backpack won't help you much if you can't reach your backpack during an emergency.