Static priority scheduling is widely used in real-time systems. But its schedulability will be reduced if priority levels of the system are insufficient. A task set may require more priority levels than the system can support. In this case, more than one task must be grouped into the same priority. This paper presents necessary and sufficient conditions for analyzing the schedulability of static priority algorithms on resources with limited priority levels. A static priority assignment algorithm (AGP) with limited priority levels is developed. As it turns out, AGP is optimal for the basic task set in the sense that the number of priority levels required by AGP is minimal and no other static priority rule can schedule a basic task set which cannot scheduled by AGP. Simulation results show that the schedulability of AGP is much higher than that of Constant Ratio Grid algorithm. AGP is significant for solving the problem of assigning priorities of tasks in embedded real-time systems.