The research introduces a priority-based fog computing model designed to mitigate delay and latency challenges in connected vehicles within smart cities. This model utilizes VANET (Vehicular Ad-hoc Networks) and fog computing as intermediaries between vehicles and the cloud, providing processing, storage, and networking capabilities. The goal is to establish a smart and autonomous transportation system, leveraging Cellular Vehicle-to-Everything (C-V2X) connectivity and roadside units (RSUs) for various vehicular applications. To enhance task processing efficiency, the research proposes an efficacy utility and a knapsack-based task scheduling algorithm for fog servers located near RSUs. The results indicate that the 0/1 Knapsack algorithm is the most effective of the four algorithms considered, as it maximizes total priority while considering both the priority and size of tasks. Overall, this research contributes to the advancement of a smart and autonomous transportation system by addressing the experiments related to delay and latency in fog adding and VANET.