Loop tasks in networked control systems consist of message tasks and control tasks that run on different resources (network and processors) and must be executed in certain order. Therefore, the execution order of message tasks and control task of a loop task is guaranteed by setting their different deadlines and arrival times. Local scheduling algorithms are adopted to schedule the tasks on every resource. The method for setting subtasks deadlines of loop tasks is presented and particle swarm optimization (PSO) algorithm is applied to optimize deadlines of control tasks. Then heuristic algorithm for assigning control tasks to processors is given and the algorithm for acquiring minimal processor number is investigated. Finally, the maximal utilization that the network can reach is analyzed and the algorithm for acquiring maximal network utilization is presented. Simulation results show that the scheduling algorithm and the PSO algorithm are effective.