进程控制【Linux】

创建一批子进程

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#define N 5

void runChild()
{
    int cnt = 10;
    while (cnt != 0)
    {
        printf("i am a child : %d , ppid:%d\n", getpid(), getppid());
        sleep(1);
        cnt--;
    }
}

int main()
{
    int i = 0;
    for (; i < N; i++)
    {
        pid_t id = fork();
        if (id == 0)
        {
            //子进程
            runChild();
            exit(0);
        }
        //父进程
        //父进程继续循环
    }
    sleep(1000);
    return 0;
}

进程终止

进程退出只有三种情况:
代码运行完毕,结果正确。
代码运行完毕,结果不正确
代码异常终止(进程崩溃)

代码异常,本质可能就是代码没有跑完
此时进程的退出码无意义,我们不关心退出码

代码是否正确,统一会采用进程的退出码来进行判断

在这里插入图片描述

查看该进程的进程退出码
$?:保存的是最近一次进程退出的时候的退出码

[cxq@iZ7xviiy0goapxtblgih6oZ lesson15]$ echo $?

在这里插入图片描述

查看错误码
在这里插入图片描述

在这里插入图片描述

errno

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

int main() 
{
    int ret = 0;
    char *p = (char*)malloc(1000 * 1000 * 1000 * 4);

    if (p == NULL) 
    {
    //errno 返回的是错误码 ,strerror可以知道错误原因
        printf("malloc error, %d %s\n", errno, strerror(errno));
        ret = errno;
    } 
    else 
    {
        printf("malloc success\n");
    }
    return ret;
}

在这里插入图片描述

进程出现异常,本质是我们的进程收到了对应的信号
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

exit与return的区别
exit在任意地方被调用,都表示调用进程直接退出
return只表示当前函数返回,还会继续向后运行

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
void show()
{
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    exit(13);//exit在任意地方被调用,都表示调用进程直接退出,如果此时换成return,return只表示当前函数返回,还会继续向后运行
    printf("end show\n");
    printf("end show\n");
    printf("end show\n");
    printf("end show\n");
    printf("end show\n");
}

int main()
{
    show();
    printf("hello Linux\n");
    return 12;
}

在这里插入图片描述

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
void show()
{
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    return ;//return只表示当前函数返回,还会继续向后运行
    exit(13);//exit在任意地方被调用,都表示调用进程直接退出
    printf("end show\n");
    printf("end show\n");
    printf("end show\n");
    printf("end show\n");
    printf("end show\n");
}

int main()
{
    show();
    printf("hello Linux\n");
    return 12;
}

在这里插入图片描述
_exit :

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
void show()
{
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    printf("hello show\n");
    _exit(14);
    printf("end show\n");
    printf("end show\n");
    printf("end show\n");
    printf("end show\n");
    printf("end show\n");
}

int main()
{
    show();
    printf("hello Linux\n");
    return 12;
}

在这里插入图片描述
_exit 与exit的区别

使用exit函数退出进程也是我们常用的方法,exit函数可以在代码中的任何地方退出进程,并且exit函数在退出进程前会做一系列工作

1、执行用户通过atexit或on_exit定义的清理函数。
2、关闭所有打开的流,所有的缓存数据均被写入。
3、调用_exit函数终止进程。
在这里插入图片描述

在这里插入图片描述

_exit()是系统调用接口,exit()是库函数
当把exit改成_exit时,使用_exit终止进程,不会刷新缓冲区的数据,所以缓冲区当中的数据将不会被输出,就不会看到you can see me 了
但是exit在终止进程之前,会冲刷缓冲区,将缓冲区的数据输出

printf一定是先把数据写入缓冲区中,合适的时候,再进行刷这个缓冲区,缓冲区绝对不在内核中,在用户区

进程等待

进程等待:通过系统调用wait/waitpid,来进行对子进程进行状态检测与回收的功能

1、子进程退出,父进程如果不读取子进程的退出信息,子进程就会变成僵尸进程,进而造成内存泄漏
2、进程一旦变成僵尸进程,那么就算是kill -9命令也无法将其杀死,因为谁也无法杀死一个已经死去的进程
3、对于一个进程来说,最关心自己的就是其父进程,因为父进程需要知道自己派给子进程的任务完成的如何
4、父进程需要通过进程等待的方式,回收子进程资源,获取子进程的退出信息

父进程通过调用wait/waitpid进行僵尸进程的回收问题

在这里插入图片描述
监控脚本

while :; do ps ajx |head -1 && ps ajx | grep testWait | grep -v grep  ; sleep 1 ; echo "------------"  ; done

在这里插入图片描述

wait是等待任意一个子进程退出

如果是多个子进程僵尸,如何利用wait回收?

  1 #include<stdio.h>
  2 #include<unistd.h>
  3 #include<stdlib.h>
  4 #include<sys/types.h>
  5 #include<sys/wait.h> 
  6 #define N 10 
  7   void     Runchild ()
  8 {
  9   int cnt =5 ;
 10   while(cnt)
 11   {
 12     printf("child pid:%d ,ppid%d\n",getpid() ,getppid());
 13     sleep(1);
 14     cnt--;
 15   }
 16 }
 17 int main()
 18 {
 19   for( int i =0 ; i < N ;i ++ )
 20   {
 21     pid_t id  =  fork();
 22     if( id ==0  )              
 23     {                   
 24       //子进程
 25       Runchild ();
 26       exit(0);    
 27     }                                                                                                                                                      
 28     //父进程      
 29     printf("create child process: %d success\n", id);
 30   }                                                  
 31   sleep(10);                                         
 32   //等待                                             
 33   for( int i = 0 ; i < N  ; i++ )
 34   {                              
 35       pid_t id   =  wait(NULL);  
 36      if( id>0 )                  
 37      {                         
 38        printf("wait %d success\n", id);
 39      }  
 40 
 41   }
 42 
 43 sleep(5);
 44   return 0 ;
 45 }

在这里插入图片描述

如果父进程在等待子进程,如果一个子进程或多个子进程不退出 ,父进程会在调用wait时,父进程就一直拿不到子进程的pid , 父进程会一直等待子进程退出,父进程这种状态叫阻塞等待

 #include<stdio.h>
  2 #include<unistd.h>
  3 #include<stdlib.h>
  4 #include<sys/types.h>
  5 #include<sys/wait.h> 
  6 #define N 10 
  7   void     Runchild ()
  8 {
  9   int cnt =5 ;
 10   while(1)
 11   {
 12     printf("child pid:%d ,ppid%d\n",getpid() ,getppid());
 13     sleep(1);
 14     cnt--;
 15   }
 16 }
 17 int main()
 18 {
 19   for( int i =0 ; i < N ;i ++ )
 20   {
 21     pid_t id  =  fork();
 22     if( id ==0  )
 23     {
 24       //子进程
 25       Runchild ();
 26       exit(0);
 27     }
 28     //父进程 
 29     printf("create child process: %d success\n", id);
 30   }
 31 //  sleep(10);                                                                                                                                             
 32   //等待
 33   for( int i = 0 ; i < N  ; i++ )
 34   {
 35       pid_t id   =  wait(NULL);
 36      if( id>0 )
 37      {
 38        printf("wait %d success\n", id);
 39      }
 40 
 41   }
 42 
 43 sleep(5);
 44   return 0 ;
 45 }

waitpid

等待指定子进程或任意子进程

在这里插入图片描述

waitpid的返回值:
1、等待成功返回被等待进程的pid。
2、如果设置了选项WNOHANG,而调用中waitpid发现没有已退出的子进程可收集,则返回0。
3、如果调用中出错,则返回-1,这时errno会被设置成相应的值以指示错误所在。

pid:待等待子进程的pid,若设置为-1,则等待任意子进程
status:输出型参数(通过指针,把函数内部的数据带出来)
获取子进程的退出状态,不关心可设置为NULL

status:操作系统会去找对应id的子进程,并且等待该子进程,如果该子进程退出 ,操作系统会将子进程的退出信息拷贝到status指针所指向的变量当中

  1 #include<stdio.h>
  2 #include<unistd.h>
  3 #include<stdlib.h>
  4 #include<sys/types.h>
  5 #include<sys/wait.h> 
  6 #define N 10 
  7   void     Runchild ()
  8 {
  9   int cnt =5 ;
 10   while(1)
 11   {
 12     printf("child pid:%d ,ppid%d\n",getpid() ,getppid());
 13     sleep(1);
 14     cnt--;
 15   }
 16 }
 17 int main()
 18 {
 45   pid_t id = fork() ;
 46   if(id <0)
 47   {
 48     perror("fork");
 49     return 1 ;
 50   }
 51   else if( id == 0 )
 52   {
 53    //child 
 54    
 55    int cnt =5 ;
 56    while(cnt)
 57    {
 58      printf("I am a child ,pid:%d , ppid:%d cnt: %d\n", getpid() , getppid() ,cnt);
 59      cnt -- ;
 60      sleep(1);
 61    }
 62      exit(1);
 63   }
 64    else // parent 
 65   {
 66     int cnt =10  ;
 67     while(cnt )
 68     {
 69      printf("I am a parent ,pid:%d , ppid:%d cnt: %d\n", getpid() , getppid() ,cnt);                                                                       
 70      cnt -- ;
 71      sleep(1); 
 72     }
 73     // pid_t ret = wait(NULL);
 74      
 75    int status =0 ;//输出型参数
 76    //操作系统会去找对应id的子进程,并且等待该子进程,如果该子进程退出 ,操作系统会将子进程的退出信息拷贝到status指针所指向的变量当中
 77    pid_t  ret = waitpid( id, &status , 0 );
 78 
 79      //等待成功
 80      if( ret ==id ) //id是子进程的pid
 81      {
 82        //status存放的是子进程的退出信息
 83        printf("wait success,ret:%d, status: %d\n", ret, status);
 84      }
 85 sleep(5);
 86 
 87 
 88   }
 89   return 0 ;
 90 }

在这里插入图片描述
为什么status是256 ?
在子进程中 ,exit函数里面,我们设置的是1
在这里插入图片描述

退出码设置的是1 ,也就是00000001,00000001就是256

子进程退出,一共会有3种退出场景
1、代码运行完毕,结果正确
2、代码运行完毕,结果不正确
3、代码异常终止

父进程等待,需要获得子进程退出的哪些信息?
1、子进程代码是否异常
2、如果没有异常,通过退出码判断来结果是否正确
不同的退出码表示不同的出错原因

status是一个整型变量,但status不能简单的当作整型来看待,status的不同比特位所代表的信息不同,具体细节如下(只研究status低16比特位)

在这里插入图片描述

 1 #include<stdio.h>
  2 #include<unistd.h>
  3 #include<stdlib.h>
  4 #include<sys/types.h>
  5 #include<sys/wait.h> 
  6 #define N 10 
  7   void     Runchild ()
  8 {
  9   int cnt =5 ;
 10   while(1)
 11   {
 12     printf("child pid:%d ,ppid%d\n",getpid() ,getppid());
 13     sleep(1);
 14     cnt--;
 15   }
 16 }
 17 int main()
 18 {
 45   pid_t id = fork() ;
 46   if(id <0)
 47   {
 48     perror("fork");
 49     return 1 ;
 50   }
 51   else if( id == 0 )                                                                                                                                                                       
 52   {
 53    //child 
 54    
 55    int cnt =5 ;
 56    while(cnt)
 57    {
 58      printf("I am a child ,pid:%d , ppid:%d cnt: %d\n", getpid() , getppid() ,cnt);
 59      cnt -- ;
 60      sleep(1);
 61    }
 62      exit(1);
 63   }
 64    else // parent 
 65   {
 66     int cnt =10  ;
 67     while(cnt )
 68     {
 69      printf("I am a parent ,pid:%d , ppid:%d cnt: %d\n", getpid() , getppid() ,cnt);
 70      cnt -- ;
 71      sleep(1); 
 72     }
 73     // pid_t ret = wait(NULL);
 74      
 75    int status =0 ;//输出型参数
 76    //操作系统会去找对应id的子进程,并且等待该子进程,如果该子进程退出 ,操作系统会将子进程的退出信息拷贝到status指针所指向的变量当中
 77    pid_t  ret = waitpid( id, &status , 0 );
 78 
 79      //等待成功
 80      if( ret ==id ) //id是子进程的pid
 81      {
 82        //status存放的是子进程的退出信息
 83        //7F 0111 1111 
 84        //0xFF
 85        printf("wait success,ret:%d, exit sig : %d, exit code:%d\n", ret, status&0x7F , (status>>8) &0xFF  ); //打印的分别是 id, 信号, 退出码
 86      }
 87 sleep(5);
 88 
 89 
 90   }
 91   return 0 ;
 92 }

在这里插入图片描述

通过收到信号判断是否异常
通过看退出码判断是否结果正确

系统当中提供了两个宏来获取退出码和退出信号
WIFEXITED(status):用于查看进程是否是正常退出,本质是检查是否收到信号
WEXITSTATUS(status):用于获取进程的退出码

exitNormal = WIFEXITED(status);  //获取退出信号,判断是否正常退出
exitCode = WEXITSTATUS(status);  //获取退出码

例如:

 1 #include<stdio.h>
  2 #include<unistd.h>
  3 #include<stdlib.h>
  4 #include<sys/types.h>
  5 #include<sys/wait.h> 
  6 #define N 10 
  7   void     Runchild ()
  8 {
  9   int cnt =5 ;
 10   while(1)
 11   {
 12     printf("child pid:%d ,ppid%d\n",getpid() ,getppid());
 13     sleep(1);
 14     cnt--;
 15   }
 16 }
 17 int main()
 18 {
 45   pid_t id = fork() ;
 46   if(id <0)
 47   {
 48     perror("fork");
 49     return 1 ;
 50   }
 51   else if( id == 0 )                                                                                                                                                                       
 52   {
 53    //child 
 54    
 55    int cnt =5 ;
 56    while(cnt)
 57    {
 58      printf("I am a child ,pid:%d , ppid:%d cnt: %d\n", getpid() , getppid() ,cnt);
 59      cnt -- ;
 60      sleep(1);
 61    }
 62      exit(1);
 63   }
 64    else // parent 
 65   {
 66     int cnt =10  ;
 67     while(cnt )
 68     {
 69      printf("I am a parent ,pid:%d , ppid:%d cnt: %d\n", getpid() , getppid() ,cnt);
 70      cnt -- ;
 71      sleep(1); 
 72     }
 73     // pid_t ret = wait(NULL);
 74      
 75    int status =0 ;//输出型参数
 76    //操作系统会去找对应id的子进程,并且等待该子进程,如果该子进程退出 ,操作系统会将子进程的退出信息拷贝到status指针所指向的变量当中
 77    pid_t  ret = waitpid( id, &status , 0 );
 78 
 79      //等待成功
 80      if( ret ==id ) //id是子进程的pid
 81      {
 82        //status存放的是子进程的退出信息
 83        //7F 0111 1111 
 84        //0xFF
 85        //printf("wait success,ret:%d, exit sig : %d, exit code:%d\n",      ret, status&0x7F , (status>>8) &0xFF  ); //打印的分别是 id, 信号, 退出码
               if(WIFEXITED(status) )
 88        {
 89            printf("进程是正常跑完的,退出码:%d\n",WIFEXITED(status));
 90        }
 91        else
 92        {
 93          printf("进程出异常了\n");
 94        }
 86      }
 87 sleep(5);
 88 
 89 
 90   }
 91   return 0 ;
 92 }

以下代码中同时创建了10个子进程
父进程再使用waitpid函数指定等待这10个子进程

  1 #include<stdio.h>
  2 #include<unistd.h>
  3 #include<stdlib.h>
  4 #include<sys/types.h>
  5 #include<sys/wait.h>
  6 #define N 10 
  7   void     Runchild ()
  8 {
  9   int cnt =5 ;
 10   while(cnt)
 11   {
 12     printf("child pid:%d ,ppid%d\n",getpid() ,getppid());
 13     sleep(1);
 14     cnt--;
 15   }
 16 }
 17 int main()
 18 {
     //创建多进程
 19   for( int i =0 ; i < N ;i ++ )
 20   {
 21     pid_t id  =  fork();
 22     if( id ==0  )
 23     {
 24       //子进程
 25       Runchild ();                                                                                                                                                                         
 26       exit(i);
 27     }
 28     //父进程 
 29     printf("create child process: %d success\n", id);
 30   }
 31 //  sleep(10);
 32   //多进程等待
 33   for( int i = 0 ; i < N  ; i++ )
 34   {
 35 //      pid_t id   =  wait(NULL);
 36      int status =0 ;
 37     pid_t id=    waitpid(-1 , &status ,0 );
 38 
 39      if( id>0 )
 40      {
 41        printf("wait %d success,exit code:%d\n", id,WEXITSTATUS(status ) )  ; //id ,退出码
 42      }
 43 
 44   }
 45 
 46 sleep(5);
108   return 0 ;
109 }

options:
1、options为0时,父进程阻塞等待
2、options为WNOHANG时,若等待的子进程没有结束,则waitpid函数直接返回0,不予以等待。若正常结束,则返回该子进程的pid

非阻塞轮询
options为WNOHANG时,父进程等待子进程中实现非阻塞

例如,父进程可以隔一段时间调用一次waitpid函数,若是等待的子进程尚未退出,则父进程可以先去做一些其他事,过一段时间再调用waitpid函数读取子进程的退出信息。

  1 #include<stdio.h>
  2 #include<unistd.h>
  3 #include<stdlib.h>
  4 #include<sys/types.h>
  5 #include<sys/wait.h> 
  6 #define N 10 
  7   void     Runchild ()
  8 {
  9   int cnt =5 ;
 10   while(cnt)
 11   {
 12     printf("child pid:%d ,ppid%d\n",getpid() ,getppid());
 13     sleep(1);
 14     cnt--;
 15   }
 16 }
 17 int main()
 18 {
 48  pid_t id = fork() ;
 49  if(id <0)
 50  {
 51    perror("fork");                                                                                                                                                                         
 52    return 1 ;
 53  }
 54  else if( id == 0 )
 55  {
 56   //child 
 57   
 58   int cnt =3 ;
 59   while(cnt)
 60   {
 61     printf("I am a child ,pid:%d , ppid:%d cnt: %d\n", getpid() , getppid() ,cnt);
 62     cnt -- ;
 63     sleep(1);
 64   }
 65     exit(11);
 66  }
 67   else // parent 
 68  {
 78   int status =0 ;//输出型参数
 79   //操作系统会去找对应id的子进程,并且等待该子进程,如果该子进程退出 ,操作系统会将子进程的退出信息拷贝到status指针所指向的变量当中
 80   while(1)  //轮询
 81   {
 82 
 83   pid_t  ret = waitpid( id, &status , WNOHANG ); //非阻塞等待
 84 
 85     //等待成功
 86     if( ret >0 ) //id是子进程的pid
 87     {
 88       //status存放的是子进程的退出信息
 89       //7F 0111 1111 
 90       //0xFF
 91      // printf("wait success,ret:%d, exit sig : %d, exit code:%d\n", ret, status&0x7F , (status>>8) &0xFF  ); //打印的分别是 id, 信号, 退出码
 92      
 93       if(WEXITSTATUS(status) )
 94       {
 95           printf("进程是正常跑完的,退出码:%d\n",WEXITSTATUS(status));
 96       }
 97       else 
 98       {
 99         printf("进程出异常了\n");
100       }
101        break;
102     }
103     else if ( ret< 0 ) 
104     {
105      printf("wait failed\n");
106      break;
107     }
108     else  //ret==0
109     {
110     printf("子进程还没有退出我再等等\n") ;
111     sleep(1);
112     }
113   }
114   sleep(3);
115 
116 
117  }
118   return 0 ;
119 }

在这里插入图片描述
如果你觉得这篇文章对你有帮助,不妨动动手指给点赞收藏加转发,给鄃鳕一个大大的关注你们的每一次支持都将转化为我前进的动力!!!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/592756.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Cisco WLC 2504控制器重启后所有AP掉线故障-系统日期时间

1 故障描述 现场1台WLC 2504控制器掉电重启后&#xff0c;所有AP均无线上线&#xff0c; 正常时共有18个AP在线&#xff0c;而当前为0 AP在线数量为0 (Cisco Controller) >show ap sumNumber of APs.................................... 0Global AP User Name..........…

【AIGC】本地部署 ollama + open-webui

在之前的篇章《【AIGC】本地部署 ollama(gguf) 与项目整合》中我们已经使用 ollama 部署了一个基于预量化&#xff08;gguf&#xff09;的 Qwen1.5 模型&#xff0c;这个模型除了提供研发使用外&#xff0c;我还想提供给公司内部使用&#xff0c;因此还需要一个 ui 交互界面。 …

麦克纳姆轮 Mecanum 小车运动学模型和动力学分析

目录 一、简介 二、运动学模型分析 1. 逆运动学方程 2. 正运动学方程 三、动力学模型 四、广泛运动学模型 一、简介 参考文献https://www.geometrie.tugraz.at/gfrerrer/publications/MecanumWheel.pdf 移动机器人的运动学模型是为了解决小车的正向运动学和逆向运动学问…

springmvc下

第二类初始化操作 multipartResolver应用 localeResolver应用 themeResolver应用 handlerMapping应用 handlerAdapter应用 handlerExceptionReslver requestToViewNameTranslator应用 viewResolver应用 flashMapManager应用 dispatcherServlet逻辑处理 processRequest处理web请…

【Flask 系统教程 5】视图进阶

类视图 在 Flask 中&#xff0c;除了使用函数视图外&#xff0c;你还可以使用类视图来处理请求。类视图提供了一种更为结构化和面向对象的方式来编写视图函数&#xff0c;使得代码组织更清晰&#xff0c;并且提供了更多的灵活性和可扩展性。 创建类视图 要创建一个类视图&am…

Docker高频使用命令

一、Docker常用命令总结 1.镜像命令管理 指令描述ls列出镜像build构建镜像来自Dockerfilehoistory查看历史镜像inspect显示一个或多个镜像的详细信息pull从镜像仓库拉取镜像push推送一个镜像仓库rm移除一个或多个镜像prune一处未使用的镜像&#xff0c;没有被标记或被任何容器…

初始化Linux或者Mac下Docker运行环境

文章目录 1 Mac下安装Docker2 Linux下安装Docker2.1 确定Linux版本2.2 安装Docker2.3 配置加速镜像 3 Docker安装校验4 安装docker-compose4.1 直接下载二进制文件4.2 移动二进制文件到系统路径4.3 设置可执行权限4.4 验证安装 1 Mac下安装Docker mac 安装 docker 还是比较方便…

哥白尼高程Copernicus DEM下载(CSDN_20240505)

哥白尼数字高程模型(Copernicus DEM, COP-DEM)由欧洲航天局(European Space Agency, 简称ESA或欧空局)发布&#xff0c;全球范围免费提供30米和90米分辨率DEM。COP-DEM是数字表面模型(DSM)&#xff0c;它表示地球表面(包括建筑物、基础设施和植被)的高程。COP-DEM是经过编辑的D…

c++set和map

目录 一、set的使用 1、set对象的创建 2、multiset 二、map的使用 1、map对象的创建 2、map的operator[] 序列式容器&#xff1a;vector、list、deque....单纯的存储数据&#xff0c;数据和数据之间没有关联 关联式容器&#xff1a;map、set.....不仅仅是存储数据&#x…

2000-2020年县域创业活跃度数据

2000-2020年县域创业活跃度数据 1、时间&#xff1a;2000-2020年 2、指标&#xff1a;地区名称、年份、行政区划代码、经度、纬度、所属城市、所属省份、年末总人口万人、户籍人口数万人、当年企业注册数目、县域创业活跃度1、县域创业活跃度2、县域创业活跃3 3、来源&#…

python数据可视化:显示两个变量间的关系散点图scatterplot()

【小白从小学Python、C、Java】 【计算机等考500强证书考研】 【Python-数据分析】 python数据可视化&#xff1a; 显示两个变量间的关系 散点图 scatterplot() [太阳]选择题 请问关于以下代码表述错误的选项是&#xff1f; import seaborn as sns import matplotlib.pyplot …

VISO流程图之子流程的使用

子流程的作用 整个流程图的框图多而且大&#xff0c;进行分块&#xff1b;让流程图简洁对于重复使用的流程&#xff0c;可以归结为一个子流程图&#xff0c;方便使用&#xff0c;避免大量的重复性工作&#xff1b; 新建子流程 方法1&#xff1a; 随便布局 框选3 和4 &#…

SQL:NOT IN与NOT EXISTS不等价

在对SQL语句进行性能优化时&#xff0c;经常用到一个技巧是将IN改写成EXISTS&#xff0c;这是等价改写&#xff0c;并没有什么问题。问题在于&#xff0c;将NOT IN改写成NOT EXISTS时&#xff0c;结果未必一样。 目录 一、举例验证二、三值逻辑简述三、附录&#xff1a;用到的S…

3.3Java全栈开发前端+后端(全栈工程师进阶之路)-前端框架VUE3框架-企业级应用-Vue组合式API

为什么要使用Composition API 一个Options API实例 在前面的课程中&#xff0c;我们都是采用 Options API&#xff08;基于选项的 API &#xff09; 来写一个组件的。下面是一个实例&#xff1a; <template> Count is: {{ count }}, doubleCount is: {{ doubleCount…

深入理解网络原理3----TCP核心特性介绍(上)【面试高频考点】

文章目录 前言TCP协议段格式一、确认应答【保证可靠性传输的机制】二、超时重传【保证可靠性传输的机制】三、连接管理机制【保证可靠性传输的机制】3.1建立连接&#xff08;TCP三次握手&#xff09;---经典面试题3.2断开连接&#xff08;四次挥手&#xff09;3.3TCP状态转换 四…

【skill】onedrive的烦人问题

Onedrive的迷惑行为 安装Onedrive&#xff0c;如果勾选了同步&#xff0c;会默认把当前用户的数个文件夹&#xff08;桌面、文档、图片、下载 等等&#xff09;移动到安装时提示的那个文件夹 查看其中的一个文件的路径&#xff1a; 这样一整&#xff0c;原来的文件收到严重影…

政安晨:【Keras机器学习示例演绎】(三十五)—— 使用 LayerScale 的类注意图像变换器

目录 简介 导入 层刻度层 随机深度层 类注意力 会说话的头注意力 前馈网络 其他模块 拼凑碎片&#xff1a;CaiT 模型 定义模型配置 模型实例化 加载预训练模型 推理工具 加载图像 获取预测 关注层可视化 结论 政安晨的个人主页&#xff1a;政安晨 欢迎 &#…

Topaz Video AI 5.0.3激活版 AI视频无损缩放增强

Topaz Video AI专注于很好地完成一些视频增强任务&#xff1a;去隔行&#xff0c;放大和运动插值。我们花了五年时间制作足够强大的人工智能模型&#xff0c;以便在真实世界的镜头上获得自然的结果。 Topaz Video AI 还将充分利用您的现代工作站&#xff0c;因为我们直接与硬件…

【数学建模】矩阵微分方程

一、说明 我相信你们中的许多人都熟悉微分方程&#xff0c;或者至少知道它们。微分方程是数学中最重要的概念之一&#xff0c;也许最著名的微分方程是布莱克-斯科尔斯方程&#xff0c;它控制着任何股票价格。 ​​ 股票价格的布莱克-斯科尔斯模型 微分方程可以由数学中的许多…

MidJourney提示词大全

大家好&#xff0c;我是无界生长。 这篇文章分享一下MidJourney提示词&#xff0c;篇幅内容有限&#xff0c;关注公众号&#xff1a;无界生长&#xff0c;后台回复&#xff1a;“MJ”&#xff0c;获取全部内容。 我是无界生长&#xff0c;如果你觉得我分享的内容对你有帮助&…
最新文章